Video Transcripts (English)
As a first step toward modeling relationships between entities in our bookstore app, let’s examine different types of relationships.
In this video, you'll learn how to identify three basic types of relationships: one-to-one, one-to-many, and many-to-many.
We’ll use the following questions to identify the relationship between two entities: can entity A be related to more than one entity B, and can entity B be related to more than one entity A.
Let’s apply these questions to Publisher and Headquarters entities.
You may remember that when we established entities in a previous unit, we included headquarters as an attribute of the publisher entity.
Let’s assume, now, that headquarters actually exists as its own entity in our app.
Can a publisher have more than one headquarters and can a headquarters have more than one publisher?
In our example, the answer to both of these questions is no. A publisher can only have one headquarters and a headquarters can only belong to one publisher.
We call this relationship one-to-one.
Next, let’s examine the relationship between printed books and review entities.
One book can have multiple reviews.
On the other hand, a single review can only be related to one book.
We call this relationship one-to-many.
To introduce the final relationship, let’s review Printed Books and Authors entities.
A book can have multiple authors and an author could have written more than one book.
This is a many-to-many relationship.
Nicely done. In this video we covered the following types of relationships: one-to-one, one-to-many, and many-to-many.
We also learned a set of questions to help us identify the relationship between two entities: can entity A be related to more than one entity B, and can entity B be related to more than one entity A.
In the next video, we’ll take a look at one of MongoDB’s super powers: Embedding vs referencing.
