When building an application, we have to map the real-world objects into a data model that fits the use case scenarios of the application. These real-world objects are related to each other to some degree. A typical blog application, for example, will have articles written by authors, comments posted to articles, categories created by authors and assigned to articles, and so on. We know from our discussion in Chapter 1, Getting Started with MongoDB that MongoDB (and NoSQL databases in general) is non-relational by nature; there are no FOREIGN KEYs or JOINs. Then how do we simulate the relation between two documents in MongoDB?
There are two ways we can do that, embedding a document within the other document, or creating a reference from one document to the other.