0
My Case
I have a table empresa
, this table has fields known as cnpj
, razão social
and login
. This same company may register another in its catalogue of companies. The company registered by it will only be visible to it, and not to others.
What I thought
I’m dealing with a case of self relationship, correct. I would put a field on the table empresa
pointing to the cnpj
of the registered company. There when I need to display, just filter through the companies registered by the company x. It has as I put the cnpj and cnpj_estrangeiro as composite primary key ?
Perfectly possible. See this answer. http://answall.com/a/8433/36350
– Marcelo Monteiro
Since I am a little weak in SQL, I would create another table and relate COMPANY 1 to COMPANY 2. I would not create anything in the COMPANY table.
– PauloHDSousa
If you put cnpj and cnpj_estrangeiro as the primary key, how will you register the first company in the bank?
– Pedro Teles
Answer explained in the link below: http://answall.com/questions/8408/howto functionRe%C3%A7%C3%A3o-between-the-same-table/8433#8433
– Allan Ramos