Archprimer
TradeoffBeginner 4 min read

SQL vs NoSQL

Structured, relational, ACID databases versus flexible, horizontally-scalable non-relational stores.

DatabaseACIDScalingSchema

By Ratish Jain · Updated

Diagram with 4 components: Application, SQL, NoSQL, NoSQL. Connections: Application → SQL (joins, tx); Application → NoSQL (key lookup); Application → NoSQL.
ServiceDatabase
SQL scales up and joins; NoSQL scales out and denormalizes.

The Decision

SQL (relational) databases store data in tables with a fixed schema and guarantee ACID transactions. NoSQL stores (document, key-value, wide-column, graph) relax the schema and often trade strict consistency for horizontal scale and flexibility. The real question isn't 'which is better' — it's 'which fits my access pattern'.

Side by Side

SQLNoSQL
SchemaFixed, enforced up frontFlexible / schema-less
ScalingVertical (scale up); sharding is hardHorizontal (scale out) by design
ConsistencyStrong (ACID)Often eventual (BASE)
JoinsFirst-classAvoided; data is denormalized
QueryRich, ad-hoc SQLOptimized for known access patterns
Best forTransactions, relationshipsMassive scale, flexible data

SQL Pros / Cons

Pros
  • ACID guarantees — money, orders, inventory.
  • Flexible ad-hoc queries and joins.
  • Mature tooling and strong consistency.
Cons
  • Harder to scale writes horizontally.
  • Rigid schema slows rapid iteration.
  • Joins get expensive at very large scale.

Decision Guide

Decision Guide

Need transactions, relationships, and strong consistency (banking, e-commerce checkout)? SQL. Need to scale to huge write volume with flexible or evolving data and simple access patterns (feeds, logs, catalogs, IoT)? NoSQL. Many real systems use both — SQL for core transactional data, NoSQL for high-volume derived data.

Real-World Examples

SQL
PostgreSQL, MySQL — banking, ERP, checkout
Document
MongoDB — catalogs, CMS, user profiles
Wide-column
Cassandra, DynamoDB — feeds, time-series at scale
Graph
Neo4j — social graphs, recommendations

Interview Questions

Can NoSQL be ACID?

Increasingly yes — DynamoDB and MongoDB support transactions on limited scopes. But NoSQL's design center is scale and flexibility; if transactions dominate your workload, SQL is usually the cleaner fit.

Why is sharding SQL painful?

Cross-shard joins and transactions break relational guarantees. You lose the very features you chose SQL for, which is why NoSQL — built to shard from day one — often wins at extreme scale.

60-Second Revision
  • →SQL = fixed schema, ACID, joins, scale up.
  • →NoSQL = flexible schema, scale out, eventual consistency.
  • →Transactions & relationships → SQL.
  • →Massive scale & simple access patterns → NoSQL.
  • →Polyglot persistence: use both where each fits.

Related

Everything on Archprimer is connected — follow the graph.