SQL and Relational Database Design
A complete course in relational databases: modelling, joins, transactions and isolation, index design, reading EXPLAIN, migrations and operating a database.
- Modules
- 06
- Lessons
- 18
- Reading time
- 11H 10M
- Words
- 35,950
What you will be able to do
- Model a domain as tables with keys and constraints that make bad data impossible.
- Write joins, aggregations and window functions that answer real questions.
- Use transactions and isolation levels with a clear idea of what each protects against.
- Design an index for a query shape rather than adding indexes and hoping.
- Read an EXPLAIN plan and tell a scan from a seek.
- Change a schema on a live database without an outage.
Before you start
Comfort with a command line and the ability to install a database server or run one in a container. No prior SQL assumed.
Almost every application bug that survives to production is a data bug. A missing constraint lets a duplicate row through, an index that did not match the query shape turns a millisecond lookup into a second-long scan, and a transaction boundary drawn in the wrong place produces a state that nothing in the code can explain.
This course treats the database as the part of the system where correctness is actually enforceable. It starts with modelling, because constraints written into the schema are the only validation that cannot be bypassed by a new code path. It moves through querying, transactions and isolation, then spends two modules on the parts people learn by accident: index design and schema change on a live system.
Every example runs on a real database with a real dataset, and every performance claim is demonstrated with an execution plan rather than asserted. The SQL is portable across PostgreSQL, MySQL and MariaDB except where a specific engine behaviour is the point, in which case it is named.
Curriculum
6 modules, 18 lessons
Thinking in tables
Relations, keys, constraints and normalisation, and treating the schema as a contract rather than a dumping ground.
3 lessons · 1H 35M
Querying
SELECT, joins, aggregation, subqueries and window functions, with the mental model behind each.
3 lessons · 1H 45M
Writing data safely
INSERT, UPDATE and DELETE, transactions, isolation levels, locking and deadlocks.
3 lessons · 2H 05M
Indexes and performance
How a B-tree index works, composite column order, cardinality traps, and reading an EXPLAIN plan.
3 lessons · 2H 05M
Schema evolution
Migrations, adding and dropping columns safely, backfilling large tables, and constraint changes.
3 lessons · 1H 40M
Operating a database
Backups that restore, monitoring the right counters, connection pooling, and capacity planning.
3 lessons · 2H
Go deeper