Chapter 2 - Lab: Many-to-Many Relationship

I can’t get my head around the additional two “correct” answers (only selected stores.address.street and items.description).

What does users.credit_cards.number have to do with items.reviews.body?

The user is writing reviews. How does a credit card have anything to do with a review?

Same for the items.sold_at and the items.reviews.body. The store has nothing to do with aa review itself. A review is given by a user and related to an item. The store has nothing to do with this.

I’m absolutely confused that non-related data can have a many-to-many relationship with each other.

Thanks for your clarification!

Hey @Daniel_Marschner,

Welcome to the MongoDB Community Forums! :leaves:

only selected stores.address.street and items.description).

This is a direct Many-to-Many relationship but this lab also expects the learner to identify the transitive many-to-many relationships as well.

For example, a user has a One-to-Many relationship with its reviews and a One-to-Many relationship with its credit cards, making a Many-to-Many relationship between the reviews and the credit cards, hence users.credit_cards.numbers and items.reviews.body has a many-to-many relationship.

Same is true for items.sold_at and items.reviews.body. From an items point of view there are possibly Many values of sold_at and Many values of reviews.body . So going from one of those two fields to another, we will traverse a Many-to-One relationship, then a One-to-Many relationship, making the whole relationship a Many-to-Many relationship.
Another way to look at it is to understand that a given review will be indirectly linked to all the stores that sell the product and that a given store has multiple reviews pertaining to the products it sells.

Feel free to reach out for anything else as well.

Regards,
Satyam

Thanks Satyam!

I just wasn’t familiar with the concept of transitive relationships and somehow the lectures didn’t really shine any proper light on it.

I‘m familiar now.

Cheers,
Daniel

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.