Skip to main content

Understanding DDIA - Chapter 01,02

· One min read
Abhishek Tripathi
Curiosity brings awareness.

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:

  1. Schema:
  • Relational: Rigid, predefined schema
  • Document: Flexible, schema-less design
  1. Data Model:
  • Relational: Data normalized across tables
  • Document: Denormalized, nested documents
  1. 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