How it works · 11 of 38 Foundation

SQL vs NoSQL databases: what is the difference?

Tables or folders

SQL vs NoSQL: A SQL database stores data in tables with fixed columns, each fact once, joined by ids, so it can answer questions nobody planned for; a NoSQL database (document or key-value) stores each record whole, shaped the way the app reads it, which is fast for those reads and slow for questions it wasn't shaped for.

Loading the animation…

Say it like this SQL keeps data in tables with fixed columns joined by ids, so it can answer questions nobody planned for; NoSQL keeps each record whole in the shape the app reads it, which is fast for the questions it was built for and slow for the rest.

Under the hood — for builders
The same order, both ways
SQL: three rows, customers (7, Asha, Pune), orders (42, 7, 14 Nov), order_items (42, Notebook, 2) and (42, Pen, 1); a JOIN on the ids rebuilds the order. Document: one record, { "order": 42, "customer": { "name": "Asha", "city": "Pune" }, "items": [ { "product": "Notebook", "qty": 2 }, { "product": "Pen", "qty": 1 } ] }.
What a question across every folder costs
In DynamoDB, a key-value and document store, a question that isn't by key is a Scan, which "reads every item in a table", at most 1 MB per request.
Terms
Schema: the agreed columns and types. Primary key: the id that picks one row or item. Join: matching rows across tables by id. Document store: keeps whole records as nested documents (MongoDB, Firestore). Key-value store: one value per key, fastest by key (DynamoDB, Redis). Partition key: the key a NoSQL store spreads data by.
Pick by your questions
Records that relate (customers, orders, payments) and questions that change: SQL (PostgreSQL, MySQL). One known lookup at huge scale (a session, a cart, a profile by user id): key-value or document.
Watch out
"Schemaless" moves the schema into your code: every reader must cope with old and new shapes. A fact copied into many documents (Asha's city) must be updated in all of them when it changes.
Measure it
List your app's top ten questions before choosing. For NoSQL, count how many need a scan; for SQL, check each uses an index.
Sources
Amazon DynamoDB Developer Guide, "Scanning tables in DynamoDB" (read November 2026).

What happens in the SQL vs NoSQL animation, step by step?

  1. One order: who bought, where they live, what they bought. A database has to store millions like it. There are two common shapes.
  2. SQL: split it into tables with fixed columns. Each fact is stored once, and ids tie the rows together: order 42 points to customer 7.
  3. NoSQL, here a document store: keep the order whole, in one folder shaped the way the app reads it. No ids to follow, and a new field needs no new column.
  4. Your turn: a million orders, and the boss asks something new: how many notebooks went to Pune this month? Which shape answers with one query, as stored?
  5. Flip the question: show order 42. The folder is one read; the tables need three lookups joined together. Each shape is quick at the questions it was shaped for.
  6. The tables answered with one query, but without help they still read every row to find Pune. How does a database jump straight to the right rows? Next: indexes.

What everyday example explains SQL vs NoSQL?

A shop's ledgers versus a filing cabinet. The ledgers keep customers in one book and orders in another, with numbers that point across: any question can be answered by reading across the books. The cabinet keeps one folder per order with everything in it: grab one folder and you have the whole order, but "how many notebooks went to Pune?" means opening every folder.

Why should a team care about SQL vs NoSQL?

Before choosing a database, list the questions your product will ask; if they change often or cross records (reports, finance, orders), start with SQL; pick NoSQL for one known lookup at very large scale, and accept that every new question may need a new index or a new copy of the data.