samedi 28 février 2015

mysql two FK in the same table

I have three tables: A, B, C. Table C has two FKs which points to A id and B id.


When I try to insert something inside C, if I fill the FK column which points to A with a valid ID and let the FK for B table empty or null or zero, MYSQL throws and error saying that I have another FK to fill.


What is the best solution for this problem?


I was thinking that it would be OK to have two C tables, one for A and the other one for B: C_A, C_B with only one FK in each of them.


I have to consider that I am using also Hibernate JPA and the solution I have will work fine. But this will mean one extra table with the same role.


What is your opinion about this problem?


Aucun commentaire:

Enregistrer un commentaire