I am confused with one to many and many to many relationship

For example… restaurants and reviews
Some would say it’s a one to many but others would say it’s many to many.

I also thought about one to many but many restaurants can have many reviews, right?


but you can look up the ‘many’ reviews by a single reviewer…

or look up the ‘many’ reviews a particular restaurant has.

or both.

The ‘key’ is having a ‘primary key’ in the table. Or more so… a column that each table shares in some fashion.

If you have a restaurant table, along with the restaurant id and review id, you would also have a ‘reviewer’ id.

If you had a reviewer table, this same ID would be shared among the tables.

uhm ok… I am still confused.

by the way, what is the diff between non-identifying and identifying relationship?
our instructor is always using non-identifying relationship connectors or lines

One helpful way to look at these relationships is about sharing; many to may relationships imply that something is shared. One restaurant can have many reviews. Many restaurants cannot share many reviews. A review makes no sense without a restaurant it’s about - the review “belongs” to the restaurant.

An example of a many to many relationship might be the category of a restaurant: say italian, thai, indian… Many restaurants may share many categories - you can have a restaurant that does italian and thai, another that does thai and indian. A category can exist without this relationship - it doesn’t “belong” to a restaurant.

Non identifying relationships and identifying relationships are related to this. If something can exist without the thing it’s related to, that’s a non identifying relationship. The relationship between category and restaurant is non identifying as you can have a category on its own. The review must have an author who wrote it and a restaurant it’s about. Those are identifying relationships.

Sponsor our Newsletter | Privacy Policy | Terms of Service