From the course: MongoDB Python Developer Associate Cert Prep
Referencing data in documents
From the course: MongoDB Python Developer Associate Cert Prep
Referencing data in documents
- Welcome. In this video, you'll learn how to model your data by using references. Before we begin, let's recap our key principle of data modeling with MongoDB. Data that is accessed together should be stored together. This means that you're storing your related data in a single document, but there are times when you might want to store related information in separate documents or maybe even in separate collections. When we want to store data in two different collections but also ensure it's clear that those collections are related, we can use references. References save the ID field of one document and another document as a link between the two. References are simple and sufficient for most use cases. Using references is sometimes called linking or data normalization. Let's go through an example. This is a fairly simple document containing information about a student who is taking multiple courses. The course ID is our reference. Referencing avoids duplication of data, and in most cases, results in smaller documents. However, with reference data, you'll need to query data from multiple documents. This can cost extra resources and impact re performance. Use this guide, which can be found in the lecture notes to help you decide whether to use embedding or referencing. Great work. Now you understand how to use references in your MongoDB documents.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to data modeling3m 8s
-
(Locked)
Types of data relationships2m 57s
-
(Locked)
Modeling data relationships2m 17s
-
(Locked)
Embedding data in documents3m 2s
-
Referencing data in documents1m 27s
-
(Locked)
Scaling a data model2m 43s
-
(Locked)
Using Atlas tools for schema help3m 26s
-
(Locked)
Introduction to MongoDB data modeling review54s
-
(Locked)
-
-