From the course: Data Modeling in MongoDB
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
One-to-one relationships - MongoDB Tutorial
From the course: Data Modeling in MongoDB
One-to-one relationships
- [Instructor] As nice as it would be, it's simply not possible to have every bit of data needed for a document in the document. And as much as we don't want to get into complex relations, like a more traditional database, there are use cases where the data needed in a document is going to be needed by other documents. In this lesson, we'll be creating some external document references and creating remote one-to-one relationships in our MongoDB models. Let's remind ourselves of the target that we're diving into, which is a single post. It's got a user, the post itself, a list of reactions, and a summary about the users that reacted to it, and a visible reply, labeled as the most relevant comment. And here's the model as we've currently defined it. You'll see that we have the post_user as an embedded document inside of a post. At this point, that model is pretty thick or deep. The user object, with its mostly static data, is…
Contents
-
-
-
-
(Locked)
Embedded documents as subdocuments3m 56s
-
(Locked)
Summary and partial documents6m 7s
-
(Locked)
One-to-one relationships6m 45s
-
(Locked)
One-to-many relationships with embedded documents7m 43s
-
(Locked)
One-to-many relationships with back references4m 3s
-
(Locked)
Many-to-many relationships5m 17s
-
(Locked)
Challenge: Create the proper relationships and summary documents for an online store1m 33s
-
(Locked)
Solution5m 52s
-
(Locked)
-
-