SQL databases store data in tables with a declared schema, let you join across tables, and give multi-row ACID transactions; PostgreSQL and MySQL are the usual choices. NoSQL is an umbrella term for stores that give up part of that model to gain something else: key-value stores such as Redis and DynamoDB, document stores such as MongoDB, wide-column stores such as Cassandra, and graph databases. Many NoSQL systems were built to partition across many machines from the start and to serve simple key-based access at very high volume. Choose SQL when the data is relational and correctness across rows matters. Choose a NoSQL store when the access pattern is known and key based, the scale is beyond a single primary, or the data fits a document, wide row or graph more naturally than tables.
SQL or NoSQL? The useful question isn't which one scales. It's how your data is shaped, and how you'll read it. A relational database keeps data in tables with a declared schema. Orders point to users and items through foreign keys, and joins stitch them back together, even for queries you haven't planned. When an order, its items and the stock level must change together, one ACID transaction commits all of them, or none. A document store takes another route. The order and its items live together in one document, filed under a partition key, like the user ID. The key is hashed to pick a partition, so a read by key goes straight to one machine. Need more capacity? Add partitions. The price is flexibility. A query that ignores the key has to ask every partition, and joins move into your application code. So start from the access pattern. Orders, payments and inventory want constraints and transactions. Feeds, sessions and carts at huge volume want a key. And many systems use both: a relational source of truth, with change events feeding the stores built for each high-volume read.
| Aspect | SQL | NoSQL |
|---|---|---|
| Data model | Tables, rows, typed columns, foreign keys | Key-value, document, wide-column or graph |
| Schema | Declared up front and changed with migrations | Flexible in the store; the application still assumes a shape |
| Queries | SQL with joins, aggregates and ad hoc filters | Mostly by key or by a pre-planned access pattern; joins limited or done in the app |
| Transactions | Multi-row and multi-table ACID by default | Varies: single-item atomicity is common; MongoDB and DynamoDB add multi-item transactions with limits |
| Scaling writes | Vertical first, then sharding (Vitess, Citus) or a distributed SQL database | Most are designed to partition horizontally |
| Consistency | Strong on the primary; replicas may lag | Ranges from tunable per query (Cassandra) to strong per key |
| Good fit | Payments, orders, inventory, accounts, anything with constraints | Sessions, carts, feeds, time series, event logs, catalogs with varied attributes |
Choose SQL when
Several entities change together and must stay consistent, like an order, its items and stock levels.
Choose NoSQL when
Reads and writes are by key at a volume a single primary cannot absorb.
Start from the queries, not the label. Write down the main reads and writes with their rough rates, then ask which store serves them with the fewest moving parts. A feed read by user ID at high volume suits a wide-column or key-value store. A checkout that touches an order, a payment and inventory suits a relational database.
The boundary has also blurred. PostgreSQL stores and indexes JSON documents. MongoDB and DynamoDB support transactions. Distributed SQL databases such as Spanner and CockroachDB scale writes horizontally while keeping SQL and strong consistency. Pick for the workload in front of you.
Large systems usually keep the source of truth for money and orders in a relational database, and put high-volume derived data, such as timelines, counters, sessions and search indexes, in stores built for that access pattern. The cost is keeping them in sync, typically through change data capture or events, and being clear about which store wins when they disagree.
Every design has a storage step, and "I will use NoSQL because it scales" is the answer interviewers hear most and like least. Name the store, tie it to the access pattern and the consistency you need, and say what you give up.
“Bookings go in PostgreSQL because a booking touches seats, orders and payments together and we need a transaction with a uniqueness constraint on the seat. The event catalog is read heavy and rarely changes, so it is cached aggressively, and the search index is a separate store fed by change events.”
Not inherently. A key lookup is fast in both. NoSQL stores can be faster for their target access pattern at very large scale because the data is laid out for it and spread across machines, and they are often slower or unable to answer queries they were not designed for.
Yes. Read replicas scale reads, and sharding layers such as Vitess and Citus or distributed SQL databases such as Spanner and CockroachDB scale writes. It takes more planning than in stores built around partitioning.
MongoDB is a NoSQL document database. It stores JSON-like documents, supports secondary indexes and aggregation pipelines, and offers multi-document transactions.
Often, yes. A common pattern is a relational source of truth for transactional data plus specialized stores for caching, search, feeds or analytics, kept in sync through events.
The full lesson: data models, guarantees and a decision process.
The storage engines under both families.
What ACID actually promises, level by level.
What changes when either kind of store outgrows one machine.
Relational inventory with strict no-double-booking.
Relational users and follows next to high-volume timeline storage.
Build the NoSQL store itself.
Ledgers, idempotency and why money wants transactions.
Metadata, media and feeds in different stores.
Knowing the trade-off is half of it
Practise saying it under follow-up questions: a timed system design interview with an AI interviewer that probes your choices and grades against a rubric.