Embedding versus Referencing
Embed data that is read together and has a bounded size, such as an address. Reference with an id when data is large, shared or changes independently, such as authors and books.
Example
// embedded
{ _id: 1, name: "Ada", address: { city: "Lagos" } }
// referenced
{ _id: 10, title: "Math", authorId: 1 }Exercise
Reference field.
authorId points to the _id
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.