Embedding (Denormalization)
← Back to DP-420 Terminology Reference
Category: Data Modeling & Partitioning
Summary: Nesting related data within a single document for fewer round trips.
Overview
Embedding is a data modeling technique where related data is denormalized and nested directly within a single document, rather than split across multiple documents or containers. It is preferred when related entities are frequently read together, have a 1:1 or 1:few relationship, and don't change independently at very different rates, since it reduces the number of round trips (and RU cost) needed to retrieve related data.
More Info & Links
DP-420 Style Practice Questions
Q1. When is embedding (denormalizing) related data within a single document generally the best modeling choice?
- A. When related entities are frequently read together and don't change independently at very different rates
- B. When related entities are updated by many different services at very different frequencies
- C. When the embedded data would grow unbounded in size
- D. When strong referential integrity across services is required
Q2. What is a potential downside of embedding too much related or frequently-changing data into one document?
- A. Increased document size and RU cost for updates to any embedded part
- B. Reduced query flexibility for filtering
- C. Inability to use a partition key
- D. Loss of schema flexibility
Answer Key
Answers are listed at the very end so you can attempt the questions first.
- Q1 (Embedding (Denormalization)): A. When related entities are frequently read together and don't change independently at very different rates — Embedding works well when related data is read together often and doesn't have wildly different update patterns.
- Q2 (Embedding (Denormalization)): A. Increased document size and RU cost for updates to any embedded part — Embedding large or frequently changing related data can bloat documents and increase the RU cost of updates.
DP-420: Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — term detail page