SQL vs NoSQL

Relational versus non-relational database models and when each fits.

Overview

What is being compared

SQL and NoSQL databases make opposite trade-offs between guarantees and scale. Neither is universally better; the right choice depends on data shape, query patterns and scale requirements.

  • Data layout — Tables with predefined schemas — Flexible schemas
  • Relationships — Enforced via foreign keys, queried with joins — Optimized for specific access patterns
  • Guarantees — ACID transactions — Some guarantees given up
  • Scaling — Vertical first, reads via replicas — Horizontal
  • Typical fits — Financial systems, ERPs, complex relationships, reporting, multi-table transactions — User profiles, product catalogs, real-time personalization, IoT sensor data, session stores, global content delivery

Where NewSQL sits

NewSQL systems such as Spanner, CockroachDB and TiDB sit between the two: horizontal scale with ACID and SQL, paid for in cost and complexity. In the grid, green is a strength, yellow is partial or varies by system, and red is the weak spot.

> [!TIP] Scaling up against sharding out, one order read as a join and as a key lookup, and the choice between SQL, NoSQL and NewSQL, step by step in Visual Explanation below.

Sign up free to read the full topic

More Comparisons topics

Start free on Cariara · Coding problems · System design studio