Lesson 1 of 30
Introduction: How This Course Works
This course teaches SQL and how relational databases work: querying, schema design, indexes, transactions, and query tuning. It ends with the SQL problems and theory questions that come up in interviews.
How the course is built
- Every lesson is a set of numbered examples. Each example is a query followed by its exact output.
- Every query was run against PostgreSQL 16, and the output shown is what PostgreSQL printed.
- All lessons use the same small sample database, so you learn the data once.
- Most SQL is standard and works in MySQL, SQL Server, Oracle, and SQLite. Where PostgreSQL differs, the lesson says so.
Lessons
| Section | Lessons |
|---|---|
| Getting Started | This introduction, the sample database |
| SQL Fundamentals | SELECT and filtering, NULL, aggregation, joins, subqueries, set operations and CTEs, window functions, functions and expressions, changing data |
| Schema Design | Data types and constraints, normalization, views and routines |
| Indexes and Performance | How indexes work, reading query plans, fixing slow queries |
| Transactions and Concurrency | ACID and transactions, isolation levels, locking and deadlocks, MVCC |
| Database Internals and Scaling | Storage and pages, WAL and crash recovery, MVCC and vacuum, query execution and the optimizer, LSM trees vs B-trees, partitioning and sharding, replication and CAP, SQL vs NoSQL |
| Interview Practice | Classic SQL problems, theory questions with answers |
How to practice
Run every query yourself. Start PostgreSQL, load the sample database, and type the examples instead of pasting them. Change a value, predict the result, then run it.
