Skip to main content
1:1 mock interviews with Sumit, scored on a real hiring rubric.Book a slot →
TOPIC 1 OF 6 · 2 MIN READ

SQL vs NoSQL: How to Choose

SQL vs NoSQL is less about which is better and more about your data and queries. Relational databases like PostgreSQL give you joins, constraints and transactions; NoSQL stores like MongoDB, DynamoDB, Redis and Cassandra trade some of that for flexible schemas, simple scaling or speed.

What you will learn

  • Name the four NoSQL families and their use cases
  • Explain when a relational database is the right default
  • Discuss schema flexibility, joins, transactions and scaling

Key concepts

Relational (SQL)

Tables with a fixed schema, foreign keys, joins and ACID transactions. PostgreSQL and MySQL. The right default for most business data: users, orders, payments.

Document

JSON-like documents (MongoDB). Good when data is read as a whole and its shape varies, such as product catalogs with different attributes per category.

Key-value

Get and set by key, extremely fast (Redis, DynamoDB). Sessions, caches, counters, rate limits.

Wide-column and graph

Wide-column (Cassandra) handles huge write volumes like events and time series. Graph (Neo4j) handles relationship-heavy queries such as "friends of friends".

Step by step

Questions to ask

  • Do I need transactions across several records (money, inventory)? → SQL
  • Do I need ad-hoc queries and reports with joins? → SQL
  • Is the access pattern simple and known, at very high scale? → key-value / wide-column
  • Is the document always read together and shaped differently? → document store
  • PostgreSQL JSONB often gives you flexible fields without leaving SQL

Examples

Same data, two models

-- SQL: normalised
CREATE TABLE users  (id bigserial PRIMARY KEY, email text UNIQUE NOT NULL);
CREATE TABLE orders (id bigserial PRIMARY KEY, user_id bigint REFERENCES users(id), total numeric(10,2), created_at timestamptz DEFAULT now());

// MongoDB: embed what is read together
{ _id: 'u1', email: 'a@x.com', recentOrders: [{ id: 'o9', total: 499, createdAt: '2026-11-01' }] }

Practise it

Try these without looking back. If you can explain each one out loud, you are ready for this question.

  • Choose a database for: a payments ledger, a chat message store, a leaderboard, a product catalog.
  • Explain when embedding is better than referencing in MongoDB.

Interview questions

What interviewers ask next on this topic. Answer out loud first, then open the model answer.

Can NoSQL databases do transactions?

Many can now. MongoDB supports multi-document ACID transactions and DynamoDB has TransactWriteItems. They are usually more limited or slower than in relational databases, so designs still try to keep each write to one document or item.

Is NoSQL always faster?

No. It is faster for the access patterns it was designed for. A query it was not modelled for (joins, ad-hoc filters) can be slow or impossible, while a well-indexed PostgreSQL handles most workloads easily.

Summary

Start with a relational database for business data; choose document, key-value, wide-column or graph stores when your access pattern, scale or data shape clearly fits them.

Stuck on this one? Talk to Sumit.

Keys: F focus mode · ← → previous / next topic · Esc leave focus