Lesson 6 of 7
Lesson 6 — SQL vs NoSQL: Choosing the Right Store
Document, key-value, graph, column and time-series databases — and when each one wins.
Learn it
Relational (SQL) databases store rows in fixed tables with strong rules: PostgreSQL, MySQL, SQLite, SQL Server, Oracle.
Document stores (MongoDB, Firestore) keep flexible JSON-like documents — great when the shape of data varies.
Key-value stores (Redis) are ultra-fast lookups by key, perfect for caches, sessions and leaderboards.
Graph databases (Neo4j) store relationships as first-class things — ideal for social networks and fraud rings.
Column stores (BigQuery, ClickHouse) crunch analytics over billions of rows; time-series stores (InfluxDB) handle sensor data.
Key terms
- Relational DB
- Tables, rows, SQL, strong schema and ACID guarantees.
- Document store
- Stores JSON-like documents with flexible structure.
- Key-value store
- Fast get/set by unique key; used for caches and sessions.
- Graph database
- Stores nodes and edges; queries traverse relationships fast.
- Eventual consistency
- Replicas converge over time rather than instantly.
Pick a store for each job
- 1Bank ledger: Relational — transactions and ACID are non-negotiable.
- 2Game leaderboard: Redis sorted sets — millisecond ranking updates.
- 3Product catalogue with varied attributes: Document store — every category has different fields.
- 4'People you may know': Graph database — multi-hop relationship traversal.
- 5IoT sensor readings: Time-series database — huge append-only writes, time-window queries.
Same question, three languages
sql-- SQL (PostgreSQL)
SELECT name FROM player WHERE score > 9000 ORDER BY score DESC LIMIT 10;
-- MongoDB aggregation
db.player.find({ score: { $gt: 9000 } }).sort({ score: -1 }).limit(10)
-- Cypher (Neo4j): friends-of-friends, awkward in SQL
MATCH (me:Player {name:'Ana'})-[:FRIEND*2]->(fof)
WHERE NOT (me)-[:FRIEND]->(fof)
RETURN DISTINCT fof.name LIMIT 10;Simple filtering looks similar everywhere. The difference shows up on relationship-heavy questions, where Cypher stays short and SQL needs repeated self-joins.
Try it
Match the workload to the best-fit database type.
Challenge
A startup builds a food delivery app: orders and payments, live courier locations every 3 seconds, restaurant menus that differ wildly, and a 'popular near you' feed. Recommend a database for each workload and justify the trade-offs.
Pick whichever way suits you — every mode earns the same bonus XP.
Write at least 40 more characters to submit.
Mark your own work
Guided walkthrough — 0/3 clues revealed
- Clue 1 locked — reveal it only if you get stuck.
- Clue 2 locked — reveal it only if you get stuck.
- Clue 3 locked — reveal it only if you get stuck.
Each clue costs 5 XP (never below 23 XP). You'd earn 45 XP right now.