The Relational Model, SQL, and Normalization
You have written thousands of database queries, and you have probably never stopped to notice that the entire relational model rests on a single, beautiful mathematical idea: a ta…
Database Systems covers: The Relational Model, SQL, and Normalization, Indexing and How Queries Run, Transactions, ACID, and Concurrency Control, Storage Internals and Recovery, Distributed Data and the ActiveRecord Lens. Year 2, Quarter 8. Includes 16 exercises and 3 projects.
This course unlocks once you've finished its prerequisite. Open prerequisite →
You have written thousands of database queries, and you have probably never stopped to notice that the entire relational model rests on a single, beautiful mathematical idea: a ta…
You have added indexes to speed up slow queries, and you have watched an index mysteriously not get used and had no idea why. This lesson ends the mystery. An index is a data stru…
Two customers hit "buy" on the last item in stock at the same instant. Two API requests both read a balance of $100, both subtract $30, both write $70 — and $30 vanishes into thin…
Beneath the SQL, the indexes, and the transactions is the layer where a database meets the disk — and this is where a lot of "why is PostgreSQL doing that?" mysteries get their an…
This lesson closes the database course by answering two questions. First: what happens when one machine can no longer hold or serve all your data? You replicate it (copies for ava…
- [ ] SQL: Write queries to find duplicate rows in a table — GROUP BY ... HAVING COUNT() > 1 - [ ] SQL: Join 3 tables (users, orders, products) — Inner join, left join, aggregate …
- [ ] SQL: Monthly revenue report with year-over-year comparison — LAG() window function - [ ] SQL: Find the Nth highest salary without LIMIT — Correlated subquery approach - [ ] …
- [ ] Implement a simple write-ahead log (WAL) in Ruby — Append operations to log, replay on crash recovery - [ ] Implement MVCC in Ruby — Version each row with transaction ID, im…
- [ ] Build a key-value database in Ruby — B-Tree index, WAL for durability, page-based storage, support GET, PUT, DELETE, SCAN; persist to disk, recover from crash
Implement a B-tree (order 4) with insert, search, delete, and range scan. Visualize the tree structure after each operation showing splits and merges. This is the core index struc…
Build a simple SQL parser in Ruby that handles SELECT ... FROM ... WHERE ... ORDER BY ... LIMIT. Parse into an AST, then generate a query plan (sequential scan vs index scan based…
- [ ] Milestone 1: Page-based storage — read/write fixed-size pages to a file - [ ] Milestone 2: B-tree index — insert, search, range scan on pages - [ ] Milestone 3: SQL parser —…
- [ ] Explain normalization up to 3NF. What is denormalization and when would you use it? - [ ] What is a B-Tree index? Why are B-Trees preferred over BSTs for database indexes? -…
13 lessons. Read in order; spiral back when you need to. By the end you'll have used the core ideas twice — once on the abstract, once on something you'll meet at work next week.