SQL or NoSQL

System Design · lesson 6 of 32 · 3 min read

Choose a datastore from the access pattern instead of from fashion, and defend the choice.

Open this lesson in the learning hub

Key points

  • Relational (PostgreSQL, MySQL) gives ACID transactions, joins, and constraints that stop bad data at the door. It is the right default.
  • A single modern Postgres node handles tens of thousands of reads per second and terabytes of data. Most systems never outgrow it.
  • Document stores (MongoDB) fit varied, self-contained records. Wide-column (Cassandra, DynamoDB) fits huge write volume with fixed queries.
  • Key-value (Redis) is for hot, small, disposable data. Search engines (Elasticsearch) are for text, never as the source of truth.
  • NoSQL is not schemaless, it is schema-on-read: the schema moved into your application code, where nothing enforces it.
  • Polyglot is normal - Postgres as the source of truth, Redis for hot reads, a search index for queries SQL is bad at.

Start relational. Move a specific workload elsewhere when you can name the query that hurts.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the System Design course, and every lesson in it is listed on the System Design contents page.