M320: Ch2 Lab: transitive Many-to-many relationship

Hi,
I’m not clear why it’s necessary to mechanically identify transitive m-2-m relationships among collections.
Moreover, it seems not to help understand relationships in practice.
Say, reviews and credit cards used for example in the lab.
user -< reviews
user -< credit cards
So, reviews >-< credit cards
Does it really suggest m-2-m to technically bridge them?

I think credit card -< reviews, 1-2-m makes sense.
However, review -< credit cards cannot establish the relationship
because one review is associated with one credit card that is used for the payment.

Guess same for stores - reviews.
store -< reviews can be true.
But likewise, review -< stores cannot be because a review is not common for all stores even for the same item.
Maybe, reviews need to have a sold_at field to be more practical.

Can you help understand the value/meaning of transitive m-2-m relationships in data modeling?
Thanks

1 Like

Hey @Gunho_Cho,

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.

Let us know if there’s still any doubt about this. I also suggest re-watching the video lecture if there’s any confusion still pending.

Regards,
Satyam

1 Like

Thanks, Satyam for clarification.
Yeah, I understand the part of indirect link but would like to know why we need to set up such mechanical relationship and when.

From your example,

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.

I doubt such modeling helps understand data relations in actuality.
store -< reviews : true
But review -< stores feels awkward.

In some sense, I suspect that the course overstretched the concept of transitive M2M relationship.
students, tutors, classes for example
class -< students
tutor -< classes
Thus, tutors >-< students. It makes sense and seems to help real relationship.

So, I wonder when we can make the best of the course’s mechanically transitive M2M relations in data modeling.

Thanks

1 Like

Hey @Gunho_Cho,

These concepts are really helpful when modelling your data. As we learn in later chapters, there are different ways to model data in MongoDB and successfully identifying relationships will prove to be much more useful and helpful then. :smile:

Regards,
Satyam

I see. Thanks.
Can you point me to specific chapter or reference for my understanding?

Hey @Gunho_Cho,

There are questions in the final exams around data modelling in different relationships too where you need to know these concepts well before answering those questions well.

Regards,
Satyam

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