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

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