From the course: MongoDB Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Data modeling

Data modeling

- [Instructor] Data modeling is a topic that deserves its own course, but I will give you a brief introduction here. The main principle to keep in mind when modeling data is that data commonly queried together should live as closely together as possible. That means, in the same document or collection. While pulling in data from another collection is possible, it is not the most performant way to use MongoDB. However, you also have to contend with processing and storage limits, such as the 16 megabyte document limit and aggregation pipeline processing limits. And operations with big documents are not as performant as with small documents. So you cannot always keep all data together. There are a few general guidelines for what to put together and what not. The first one is if there is a one-to-one relationship between a document and another piece of data, like with a document about a person and a date of birth, store them…

Contents