Restarting indexes for each new client

1

I need your help. I have a small system that allows the registration of companies, each of which may contain one or more associates. Here's a summary of the tables:

//Tabela Empresa
emp_codigo (chave primaria)
emp_nome_empresa
emp_telefone

//Tabela Associados
ass_codigo (chave primaria)
ass_empresa (chave estrangeira -> emp_codigo)
ass_nome
ass_telefone

I register companies with their associates. I would like, however, to configure it so that for each new company registered, the registration of its respective associates would start from code 1, and not follow the default sequence of the auto increment of the primary key (ass_codigo).

In this case, I thought of creating another field (ass_codigo2) for the associated table, and do this processing manually. Is there a more automatic way for this within phpMyAdmin?

    
asked by anonymous 01.06.2017 / 14:16

1 answer

0

So I understand, for this to work you would have to create two index columns, one to be the primary key, and one to be the associated code. So the associated code can always start from 1, but if it's a primary key like you're using, there's no way around it.

    
01.06.2017 / 14:19