SQL vs NoSQL
System Design: lesson 9 of 15
Fixed columns and joins, or flexible documents.
Lesson 9 of 15 · 6 min
SQL vs NoSQL
Step 1 of 12
The same invoice, two shapes. The question is which side pays: writes, or reads.
The Idea
A relational database enforces a schema, stores each fact once, and joins tables at query time with transactional guarantees. A document store keeps whole objects together, lets fields vary between records, and expects you to duplicate data so a read needs no join. The question is which side pays: writes, or reads.
Real-World Example
A garage runs both. Invoices live in strict columns — parts, labour, tax — because the totals must reconcile and nothing may be half-written. Inspection notes do not: a motorcycle check has fields a van check never heard of, and nobody wants a schema change per vehicle type.
The Tradeoff
Schemaless does not mean structure-free; the structure just moves into application code, where nothing enforces it. Duplicated data means every copy needs updating on write. Reach for documents when a shape genuinely varies and is read whole — not as a way to avoid designing the data.
Your turn
Put the steps in the right order.
- Check whether that shape is stable across every record
- Pick the store whose cost lands where you still have headroom
- List the queries this feature actually has to answer
- Decide whether a write must be all-or-nothing across entities
Mini quiz
1 / 3