Databases

SQL vs NoSQL

SQL (relational) databases store data in tables with a fixed schema and use SQL for queries. NoSQL databases cover document, key-value, column, and graph stores with flexible schemas.

Side-by-side comparison

SQLNoSQL
SchemaFixed, enforcedFlexible / dynamic
Query languageSQL (standardized)Varies by database
RelationshipsJoins, foreign keysDenormalized / embedded
TransactionsStrong ACIDVaries (often eventual consistency)
ScalingVertical (mostly)Horizontal (designed for it)

When to use SQL

  • Structured data with clear relationships
  • You need strong consistency and transactions
  • Complex queries and reporting

When to use NoSQL

  • Rapidly changing or unstructured data
  • Massive horizontal scale
  • High write throughput with flexible documents

Bottom line

Choose SQL for structured, relational data needing strong consistency. Choose NoSQL for flexible schemas and horizontal scale. Many systems use both.

More comparisons