Module · Backend Engineer
Relational Databases
Schemas that survive contact with reality, and migrations that can be rolled back.
TOPIC 01
Schemas & Indexes
Put the constraints in the database, and index the queries you actually run.
What you'll practice
- Design Tables With Constraints — guided · beginner
- Index the Queries You Run — practice · intermediate
A command you'll meet
cat ~/backend/db/schema.sqlThe database is the last line of defence. Open the task below for the full walkthrough.
Hands-On Tasks in This Topic (2)
Design Tables With Constraints
Application code has bugs, constraints do not. Write the schema with the keys, the nullability and the foreign keys spelled out.
Index the Queries You Run
An index is a bet on the queries you actually run. Write the composite indexes for the two hot paths of the orders table.
TOPIC 02
Migrations & Transactions
Ship schema changes without downtime, and keep transactions doing what you think.
What you'll practice
- Write a Reversible Migration — practice · intermediate
- Pick the Right Isolation Level — challenge · advanced
A command you'll meet
cat ~/backend/db/migrations/001_create_orders.sqlEvery migration needs a way back. Open the task below for the full walkthrough.
Hands-On Tasks in This Topic (2)
Write a Reversible Migration
A migration that cannot be undone is a migration you cannot deploy on a Friday. Write the change and the way back.
Pick the Right Isolation Level
Isolation levels trade correctness for concurrency. Write the policy for each workload and name the anomaly each one prevents.