Skip to content
Advertisement

Can somebody give a practical example of a many to many relationship?

I learned about many-to-many relationships in College, and I never really understood them. So far I’ve been working with one-to-many relationships which are easy to understand and deal with.

Can somebody please give a practical example of a many-to-many relationship, and explain why we need a bridging table for it. Plus, do you need a bridging table for a one-to-many relationship as well? As far as I understand you don’t need a bridging table for it, but a friend of mine recently told me otherwise.

Advertisement

Answer

One-to-many & many-to-many relationships are not the property of the data rather the relationship itself. And yes you do need bridging/third table for many-to-many relationship in perfect normalized RDBMS world. Lets see each of it with real life example:

One-to-many relationship: When one row of table A can be linked to one or more rows of table B.

Real Life Example: A car manufacturer makes multiple models of the cars, but a same car model can’t be manufactured by two manufacturers.

Data Model:

enter image description here

Many-to-many relationship: When one row of table A can be linked to one or more rows of table B, and vice-versa.

Real Life Example: A user can belong to multiple community, and a community can have multiple users.

Data Model:

enter image description here

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