Interview Q&A / System Design

BeginnerIn-depth3 min readUpdated 2 Oct 2026

How do you choose between a SQL and a NoSQL database?

SHORT ANSWER

Choose SQL when data is relational, you need joins, transactions and flexible queries, and the schema is fairly stable. Choose NoSQL when you need a flexible schema, very high scale for simple access patterns known in advance, or a data model like documents, key-value or graphs. Many systems use both.

Explain it simply

A SQL database is like a set of neat Excel sheets with fixed columns, linked to each other by IDs. The students sheet links to marks by roll number. Because the structure is fixed and linked, you can ask almost any question later: "average marks of girls from Ranchi in maths".

A NoSQL database is a family of other shapes. A document store is like keeping one folder per student with everything inside, and folders can look different from each other. A key-value store is like a locker: give the key, get the value, very fast. Others store wide columns or graphs of connections.

SQL gives you structure and guarantees. NoSQL gives you flexibility and easier scale-out, if you know how you will read the data.

Example

An online learning app:

text
SQL (PostgreSQL)
  users, courses, payments, enrollments
  - payment and enrollment must succeed or fail together -> transaction
  - admin reports change every month                     -> ad hoc SQL

Document store (MongoDB)
  course content: lessons with varied fields (video, quiz, code exercise)
  - each lesson has a different shape                      -> flexible schema

Key-value (Redis / DynamoDB)
  sessions, rate-limit counters, "continue watching" position
  - lookup by user ID only, huge volume                    -> simple and fast

How it works

SQL (relational)NoSQL
Data modelTables, rows, fixed columnsDocuments, key-value, wide-column, graph
SchemaDefined up front, changed with migrationsFlexible, often per record
QueriesRich SQL, joins, aggregationsUsually by key or index; joins limited or absent
TransactionsStrong ACID across rows and tablesVaries; often per item, some support multi-item
ScalingScale up, read replicas; sharding takes effortMany are designed to shard and scale out
ExamplesPostgreSQL, MySQL, SQL ServerMongoDB, Cassandra, DynamoDB, Redis, Neo4j

Questions to ask before choosing

  1. Is the data naturally related (users, orders, products)? That points to SQL.
  2. Do I need multi-row transactions, like debit one account and credit another? SQL is the safer default.
  3. Do I know all my query patterns up front, and are they simple lookups at huge scale? NoSQL fits well.
  4. Does each record have a different shape, or does the shape change often? A document store helps.
  5. Is the data about connections, like "friends of friends"? Consider a graph database.

Real-world use

Payments, banking, orders and inventory almost always live in SQL databases because correctness matters most. Chat messages, activity feeds, IoT readings and analytics events often go to NoSQL stores built for high write volume. A UPI-scale system may keep the ledger in a relational store while sending event streams and notifications through NoSQL and queues. This mix is called polyglot persistence.

Common mistakes

  • Picking NoSQL "because it scales" for an app with ten thousand users and complex relational data.
  • Thinking NoSQL means "no schema". The schema still exists; it just lives in your code instead of the database.
  • Thinking SQL cannot scale. Relational databases run some of the largest systems in the world with replicas, caching and sharding.
  • Choosing a database before listing the queries the app will run.

What to say in the interview

"I start from the data and the queries. If the data is relational, needs transactions across records, or the queries will change over time, I pick a SQL database like PostgreSQL. If the access patterns are simple and known, like lookups by user ID, the volume is very high, or the records vary in shape, I'd consider NoSQL: a document store for flexible records, key-value for sessions and counters, wide-column for heavy write workloads, a graph database for relationships. In many real systems I'd use SQL as the source of truth and add NoSQL for specific high-scale paths."

Follow-up questions

  • What does ACID stand for?
  • What is eventual consistency, and when is it acceptable?
  • How would you scale a PostgreSQL database that has become slow?
  • Would you store an e-commerce product catalogue in SQL or a document store?

Go deeper

Read these once the basics above feel easy.

PostgreSQL supports JSON columns with indexes, so a relational database can hold some flexible data without a separate store. Denormalisation in NoSQL means duplicating data so one read gets everything, at the cost of keeping copies in sync on updates.

#system-design#databases#sql#nosql

Related questions

Practise more System Design questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open System Design quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.