2
How can I relate a table(entity) to more than one entity in the Mysql database? following the following example...
I have the tables: fornecedores
, clientes
and telefones
.
- The
fornecedores
, may have more than one phone. - The
clientes
, may also have more than one phone.
To solve this problem, I created a relationship N:N
, where a fornecedor
may have several telefones
, but one phone does not belong to several fornecedores
. That’s right, same for clientes
, where a customer may have several telefones
, but one phone does not belong to several clientes
.
With this relationship N:N, an intermediate table was created between fornecedores
and telefones
, and also between clientes
and telefones
.
How could I solve this problem without having a phone table to relate to fornecedores
, and another phone table to relate to clientes
? without it being N:N
?
hehe... cool Kra. I think I’ll work polymorphically anyway. Even, as the system will be in PHP and I will use Laravel, it already has by default in his ORM, the way to work as you explained.
– paulomartinhago
@paulomartinhago I’m sure this is the best and least painful way (given the circumstances), you can bet. ;)
– felipsmartins