Relational to Document Model / Design Relationships

1:54
As a first step towards 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 headquarter 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 reviews 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 can write 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 superpowers, embedding versus referencing.