Skip to content
Advertisement

Should I create a Joint table or add foreign key

I’m busy designing a database for my app, I made the relationship between tables… and after, I realized that instead of using foreign key and place it in another table I can only use a new joint table that will contain primary key for each table.

Not sure if any one used to achieve it?

Also Microsoft in its ASP.Net MVC template on this below picture created an additional table named **UsersInRoles (Joint table) for Users and Roles instead of adding a foreign key in the many table.** enter image description here

PS : I’m not referring to foreign key in terms of constraint but instead in design perspective (General Database design).

Advertisement

Answer

It’s unclear what DBMS you’re using, but personally I would prefer using foreign keys because many DBMS and other related products has built in support related to foreign keys. Also, a joint/mapping table will add redundancy of data, compared to using foreign keys.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement