SQL vs NoSQL Databases

Choosing between ACID relational schemas and horizontally scalable Document, Key-Value (KV), Wide-Column, and Graph stores

Difficulty: Beginner · Read time: 8 min · Access: Free Interactive Lesson

How It Works

Relational databases using SQL (Structured Query Language) store normalized tables with foreign keys, complex JOIN operations across tables, and strict ACID (Atomicity, Consistency, Isolation, Durability) transactions. NoSQL ("Not Only SQL") databases trade strict cross-table joins and rigid schemas for flexible data models and effortless horizontal sharding across Document stores (MongoDB storing JSON — JavaScript Object Notation), Key-Value (KV) stores (Redis, Amazon DynamoDB), Wide-Column stores (Apache Cassandra, ScyllaDB), and Graph engines (Neo4j).

Why It Matters

Picking the wrong database model forces expensive rewrites once traffic scales: financial ledgers and inventory systems need ACID transactions to prevent double-spending, whereas IoT (Internet of Things) sensor streams or social graphs collapse under relational self-joins and single-node write ceilings.

Interactive Architecture Scenarios

  • Polyglot Persistence in E-Commerce
  • Failure Mode: Relational Joins Forced onto NoSQL KV

Key Terms & Short Forms

  • SQL (Structured Query Language): Standard declarative language used by Relational Database Management Systems (RDBMS) like PostgreSQL and MySQL to query structured tables and enforce schemas.
  • ACID (Atomicity, Consistency, Isolation, Durability): Set of transaction guarantees ensuring multi-step writes either all succeed or all roll back cleanly, never leaving half-written financial or inventory state.
  • KV Store (Key-Value Store): Simplest NoSQL database model (like Redis or DynamoDB) mapping an opaque key directly to a value blob for O(1) sub-millisecond lookups by ID.
  • Wide-Column (Wide-Column / Partitioned Row Store): Distributed NoSQL model (like Cassandra or ScyllaDB) organizing data by partition key and clustering columns for massive linear write throughput.
  • JSON / BSON (JavaScript Object Notation / Binary JSON): Self-describing nested document formats used by Document databases like MongoDB so each product or user record can carry varying attributes.
  • OLTP vs. OLAP (Online Transaction Processing vs. Online Analytical Processing): OLTP handles millions of tiny real-time user reads/writes (checkout, login); OLAP runs heavy column-scan aggregations across billions of historical rows.
  • Polyglot Persistence (Multi-Engine Storage Architecture): Combining specialized databases within one product (e.g., PostgreSQL for billing + Redis for sessions + Elasticsearch for text search) instead of forcing one engine to do everything.

Related Lessons in Databases & Storage Internals