0:00
0% complete
LearnStep 1 of 2
Embedding vs Referencing
Learning Objectives
- •Understand embedding
- •Use references
- •Choose the right pattern
Lesson Outline
LearnStep 1/2
Embedding vs Referencing
python
Embedding Advantages
- Single read operation
- Atomic updates within document
- Better read performance
Embedding Disadvantages
- Data duplication
- Document size limit
- Updates to embedded data require multiple updates
Referencing (Normalization)
python
Referencing Advantages
- No data duplication
- Smaller documents
- Easy to update source data
Referencing Disadvantages
- Multiple queries or $lookup needed
- No atomic operations across collections
Using $lookup (Join)
python
Hybrid Approach
python
Pattern: Subset Pattern
python