SQL vs NoSQL
Pick the store based on access patterns — ACID transactions vs horizontal write scale and flexible schema.
Interview tip Lead with a 30-second definition, then one real system example and name 2–3 designs where SQL vs NoSQL is non-negotiable.
① What it is (30 seconds)
Pick the store based on access patterns — ACID transactions vs horizontal write scale and flexible schema.
② How it works in system design
SQL (PostgreSQL): joins, constraints, transactions. NoSQL families: wide-column (Cassandra writes), document (Mongo flexible JSON), key-value (Redis speed), search (Elasticsearch text).
Typical placement
Client→Edge / Gateway→SQL→Services→Data stores
③ Concrete system design example
Scenario: E-commerce: PostgreSQL for orders + payments (ACID). Redis for cart session. Elasticsearch for product search. S3 for product images.
④ Important interview Q&A
| Question | Answer |
|---|---|
| When SQL wins? | Financial ledger, inventory, relationships needing joins and strong constraints. |
| When Cassandra wins? | High write throughput, time-series, tolerate eventual consistency per row. |
| Can you mix? | Polyglot persistence — each service owns its store optimized for its pattern. |
⑤ Seen in these system designs
- Ticket Booking — ACID seats
- News Feed — Cassandra feeds
- Quora — SQL + Cassandra mix
In interviews, after explaining the concept, say: "This shows up directly in …" and link two designs.
⑥ Revision checklist
- Access pattern first
- ACID needs stated
- Polyglot example
- No buzzword-only picks