dimanche 8 juin 2014

Foreign Key in SQL pivot table - database design


Vote count:

0




I am using DBDesigner 4 for designing my database relations.


I have a users table and a recipes table. One user can own many recipes but one recipe cannot be owned by many users. This relationship is shown by the user_recipes relation in the picture. (A one-to-many relationship from users to recipes).


However, recipes can be liked by users. Many users can like many recipes. This is a many-to-many relationship between users and recipes and the pivot table for this is users_like_recipes.


But when I create this pivot table, I only need the users_id and recipes_id column. The recipes_users_id column is getting added on its own and I am not able to remove it. It says the third column has come from another Relation which is defined in the model. I guess its the user_recipes relation.


When I remove the user_recipes relation, I get the pivot table like I want to.


But I need the user_recipes relation too!


Please. Any help would be appreciated.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire