Restarting indexes for each new client

Asked

Viewed 16 times

1

I need help from you. I have a small system that allows the registration of companies, and each one can contain one or more members. See 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 due associates. I would, however, like to configure it so that, for each new registered company, the registration of their respective members start from code 1, and do not follow the standard sequence of the primary key auto increment (ass_codigo).

In this case, I thought about creating another field (ass_code 2) for the associated table, and doing this treatment manually. There is a more automatic way to do this within phpMyAdmin?

1 answer

0

From what I understand, for this to work you would have to create two columns of indexes, one to be the primary key, and one to be the code of the associate. So the associate code can always start from 1, but if it is a primary key as you are using it, there is no way.

  • That’s right, Ronivaldo, I thought I’d create a second field for that. Since the primary key already exists (ass_code), it would create "ass_code 2", for example, which would be the associate’s "manipulable" code.

  • It’s the right thing to do.

  • Blz, thank you Ronivaldo

Browser other questions tagged

You are not signed in. Login or sign up in order to post.