AI Hints
Home›System Design Tutorial›Database Families
System Design · Lesson 37 of 120

SQL vs NoSQL

Two families.

⏱ 2 min read▶ Video at 43:01🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Almost every system needs a database, and the first big choice is between two families. Relational databases, which use SQL. And No SQL databases, which come in many shapes.

SQL vs NoSQL
From the video: SQL vs NoSQL
  • Every system stores data
  • Relational: SQL
  • NoSQL: many shapes

Two families

A relational database stores data in tables, with a fixed set of columns, and links between tables. It supports joins and strong transactions. Postgres and MySQL are examples. No SQL databases relax some of these rules. They often have flexible shapes, and are built to spread across many machines easily.

Relational (SQL)

  • Tables, fixed columnsJoins and transactionsPostgres, MySQL

NoSQL

  • Flexible shapesSpread across machinesRedis, MongoDB, Cassandra

When to choose which

Here's a simple guide. If your data has clear relationships, like customers, orders, and products, and correctness matters, start with SQL. If you need massive scale for simple lookups, a flexible shape, or very high write rates, consider No SQL. Most companies use both.

NeedLean towards
Clear relationships, joinsSQL
Money, strong correctnessSQL
Huge scale, simple lookupsNoSQL
Flexible, changing shapeNoSQL
Very high write rateNoSQL

Summary

Relational databases give tables, joins, and transactions. No SQL databases trade some of that for flexibility and scale. When unsure, start with SQL. Next, the four main kinds of No SQL.

Key takeaways
  • SQL: structure and safety
  • NoSQL: scale and flexibility
  • Start with SQL
Next up: Kinds of NoSQL — key-value, document, wide-column, graph