Stage 3
Stage 3: Advanced — modeling, writing and Postgres features
Goal: Turn requirements into a normalised schema with the right constraints, change data safely and in bulk, reason about transactions and concurrency, and use views, functions, triggers, JSONB and full-text search. Time: about 2 weeks at ~45–60 minutes a day (~20 hours including the project) · Level: requires Stages 1–2
Parts in this stage
Do them in order — the project at the end uses every part. Lessons still run on shopdb (reseed any time); several build new objects inside it on purpose.
| Part | Topic | You will be able to | Time |
|---|---|---|---|
| 9 | Data modeling | Turn requirements into a 3NF design with the right keys | ~2 h |
| 10 | Building schemas (DDL) | Enforce every rule with named, violation-tested constraints | ~2.5 h |
| 11 | Changing data (DML) | Write, upsert, merge and bulk-load safely, with receipts | ~2.5 h |
| 12 | Transactions and concurrency | Reason about MVCC, isolation, locks, queues and deadlocks | ~2.5 h |
| 13 | Reusable logic | Views, matviews, recursion, functions, procedures, triggers | ~2.5 h |
| 14 | Semi-structured data and search | Arrays, JSONB, SQL/JSON, full-text and fuzzy search | ~2.5 h |
| 🏁 | Project: The booking system | A schema that cannot be double-booked, proven live | ~5–6 h |
How every part is organised
part-NN-topic/
├── README.md ← 1. read the lesson, running every query as you go
├── examples/ ← 2. runnable .sql files for the lesson's examples (\i them)
├── exercises.md ← 3. solve the practice questions yourself
└── solutions/ ← 4. only then compare with the solution .sql files
Every output printed in a lesson comes from a real run against PostgreSQL 17 — the two-terminal concurrency transcripts included. psql -d shopdb -f shopdb.sql resets your data.
How to study each part
- Part 12's drills genuinely need two psql windows — do not skip them; concurrency is learned through the fingertips.
- After writing any constraint, break it on purpose. An untested rule is a hope, not a rule.
- Wrap every risky write in BEGIN until the habits are reflexes.
- The project is the exam: build it from the brief before opening the reference files.
Finish line
You are done with Stage 3 when all six acceptance checks in the booking project behave exactly as documented and your two-terminal race ends in one booking and one constraint error. Then head to Stage 4: Performance & internals.