Understanding DDIA - Chapter 01,02
· One min read
Question
Explain the key differences between relational databases and document databases. When would you choose one over the other?
Click to Flip
Solution
Here are the key differences between relational and document databases:
- Schema:
- Relational: Rigid, predefined schema
- Document: Flexible, schema-less design
- Data Model:
- Relational: Data normalized across tables
- Document: Denormalized, nested documents
- Scalability:
- Relational: Vertical scaling primarily
- Document: Easier horizontal scaling
Choose Relational when:
- Data consistency is crucial
- Complex queries and joins are needed
- ACID compliance is required
Choose Document when:
- Schema flexibility is needed
- Rapid prototyping
- Handling large amounts of unstructured data
- Horizontal scaling is a priority
Click to Flip