Database Engineering
How data is stored, found, kept correct under concurrency, and run in production.
- 1 · Foundation
- Assumes no database knowledge
- 2 · Core
- Assumes you write SQL
- 3 · Advanced
- How the engine works inside
- 4 · Expert
- Running and designing it under real load and failure
Data and storage basics
Explain what a database does that files do not, show it with your own experiments, and choose a kind of database for a workload.
- 01What data is, and why we need a databaseFoundation
Explain why a program's state needs more than memory and files, and name what a database system adds.
- Where a program's data livesConcept · 4 min
- What a database system does for youConcept · 5 min
- Should this be a file or a database?Decision · 4 min
- 02Plain files, CSV, JSON and the cost of DIY storageFoundation
Build a file-based store, measure how it slows down and breaks, and fix the failures you can, so you know exactly what a database is saving you from.
Helps to know first: What data is, and why we need a database
- How programs store records in filesConcept · 4 min
- Lab: build a JSON file store and break itLab · 7 min
- Making file storage safe, and what's still missingConcept · 4 min
- 03Database types and how to choose oneFoundation · coming soon
Relational thinking and SQL fundamentals
Model data as related tables and write correct SQL to read and change it, including the NULL, join and grouping cases that trip people up.
- 04Relational database conceptsFoundation
Read a relational schema, explain what its keys guarantee, and spot designs that will corrupt or hide data.
Helps to know first: What data is, and why we need a database
- Tables, rows and columnsConcept · 4 min
- Keys and relationshipsConcept · 3 min
- Review a schemaDecision · 4 min
- 05Install PostgreSQL and learn the environmentFoundation
Run PostgreSQL locally, connect with psql, load the practice database, and know what you are connected to.
Helps to know first: Relational database concepts
- Lab: install PostgreSQL and connectLab · 3 min
- What you are connected toConcept · 2 min
- Find your way around psqlLab · 3 min
- 06SQL basics: reading dataFoundation
Write SELECT queries that filter, sort and limit correctly, explain the order a query is evaluated in, and predict what NULL does to a condition.
Helps to know first: Install PostgreSQL and learn the environment
- SELECT, WHERE, ORDER BY and LIMITConcept · 3 min
- NULL and three-valued logicConcept · 3 min
- Practice: questions about the shopLab · 3 min
- 07SQL data modificationFoundation
Insert, update, delete and upsert rows, see exactly which rows changed, and make every data change safe to check before it is kept.
Helps to know first: SQL basics: reading data
- INSERT, UPDATE, DELETE and RETURNINGConcept · 3 min
- Insert or update: ON CONFLICTConcept · 2 min
- Review a data fixDecision · 3 min
- 08SQL types and the type systemFoundation
Choose column types that store values exactly as the business means them, especially money, text and time, and predict where the wrong type silently changes data.
Helps to know first: SQL data modification
- Choosing column typesConcept · 3 min
- Dates, times and time zonesConcept · 3 min
- Review a table's typesDecision · 3 min
- 09Constraints and data integrityFoundation
Turn every rule your data must obey into a constraint the database enforces, and predict how each one treats NULL and deletes.
Helps to know first: SQL types and the type system
- NOT NULL, UNIQUE and CHECKConcept · 3 min
- Foreign keys and what happens on deleteConcept · 3 min
- Lab: try to break the rulesLab · 4 min
- 10Joins and relational queryingFoundation
Combine tables with the right kind of join, keep or drop unmatched rows on purpose, and recognise when a join is multiplying rows.
Helps to know first: SQL basics: reading data, Relational database concepts
- Inner and outer joinsConcept · 4 min
- Semi-joins and anti-joins: EXISTS and NOT EXISTSConcept · 3 min
- Investigate: why did customers get the email three times?Lab · 3 min
- 11Aggregation and groupingFoundation
Summarise data with aggregates and GROUP BY, filter groups with HAVING, and catch the NULL and fan-out cases that make totals wrong.
Helps to know first: Joins and relational querying
- Aggregates and GROUP BYConcept · 3 min
- HAVING, FILTER and conditional aggregationConcept · 2 min
- Investigate: why does the report show too many orders?Lab · 4 min
- 12Subqueries and query compositionFoundation
Build answers from smaller queries (scalar, list, correlated and derived-table subqueries) and avoid the NOT IN trap that silently returns nothing.
Helps to know first: Aggregation and grouping
- Scalar, list, correlated and derived-table subqueriesConcept · 3 min
- The NOT IN trapConcept · 3 min
- Practice: compose queriesLab · 3 min
Data modeling and advanced SQL
- 13Normalization and schema designCore · coming soon
- 14Common table expressions (CTEs)Core · coming soon
- 15Set operations and advanced expressionsCore · coming soon
- 16Window functionsCore · coming soon
- 17Pagination and large result setsCore · coming soon
- 18Views, materialized views and derived dataCore · coming soon
- 19Functions, procedures and triggersCore · coming soon
- 20JSON and semi-structured data in PostgreSQLCore · coming soon
How Postgres stores and finds data
Explain what happens on disk when a row is written or found, and predict what an index will cost and buy.
- 21How a table is stored on diskAdvanced · coming soon
- 22Buffer cache, I/O and memoryAdvanced · coming soon
- 23Write-ahead loggingAdvanced · coming soon
- 24B-tree indexesAdvanced
Predict when a B-tree index helps, when PostgreSQL ignores it, and what it costs on every write.
Helps to know first: How a table is stored on disk
- Why indexes existConcept · 5 min
- How a B+tree finds a rowConcept · 5 min
- Lab: measure what an index buys and costsLab · 6 min
- Should this index ship?Decision · 6 min
- 25PostgreSQL index typesAdvanced · coming soon
- 26Composite indexes and index designAdvanced · coming soon
- 27Heap access, the visibility map and MVCC storageAdvanced · coming soon
Query planning and performance
- 28How PostgreSQL executes a queryAdvanced · coming soon
- 29EXPLAIN and EXPLAIN ANALYZEAdvanced · coming soon
- 30Query optimization patternsAdvanced · coming soon
- 31Statistics and the query plannerAdvanced · coming soon
- 32Benchmarking and performance measurementAdvanced · coming soon
- 33Production observability and query diagnosisAdvanced · coming soon
Transactions, MVCC and concurrency
- 34Transactions and ACIDAdvanced · coming soon
- 35MVCC: multi-version concurrency controlAdvanced · coming soon
- 36Isolation levels and anomaliesAdvanced · coming soon
- 37Locks and locking strategiesAdvanced · coming soon
- 38Race conditions and correct state transitionsAdvanced · coming soon
- 39Deadlocks, timeouts and failure recoveryAdvanced · coming soon
Running Postgres in production
- 40Database migrations and schema evolutionExpert · coming soon
- 41Vacuum, autovacuum and bloatExpert · coming soon
- 42PartitioningExpert · coming soon
- 43Advanced data types and specialized queryingExpert · coming soon
- 44PostgreSQL security and multi-tenancyExpert · coming soon
- 45Backups, restore and point-in-time recoveryExpert · coming soon
- 46Replication, high availability and failoverExpert · coming soon
- 47Connection management and poolingExpert · coming soon
Databases inside backend systems
- 48Database integration in backend applicationsExpert · coming soon
- 49Idempotency, retries and exactly-once effectsExpert · coming soon
- 50Background jobs, queues and work distributionExpert · coming soon
- 51Caching and derived stateExpert · coming soon
- 52Multi-tenant data architectureExpert · coming soon
Outgrowing one database
- 53Database bottlenecks and capacity planningExpert · coming soon
- 54Read scaling and write scalingExpert · coming soon
- 55Replication and consistency modelsExpert · coming soon
- 56Sharding and partitioning across machinesExpert · coming soon
- 57Distributed transactions and coordinationExpert · coming soon
- 58Consensus, leader election and distributed coordinationExpert · coming soon
- 59Event sourcing, CQRS and change data captureExpert · coming soon
- 60Distributed data system designExpert · coming soon
Postgres internals, deeper
- 61PostgreSQL architecture and source codeExpert · coming soon
- 62WAL, crash recovery and durability internalsExpert · coming soon
- 63PostgreSQL concurrency internalsExpert · coming soon
- 64Extensions and the PostgreSQL ecosystemExpert · coming soon
Other databases, compared to Postgres
- 65SQLite and embedded databasesExpert · coming soon
- 66MySQL and MariaDBExpert · coming soon
- 67MongoDB and document databasesExpert · coming soon
- 68Redis and key-value databasesExpert · coming soon
- 69ScyllaDB and Cassandra: wide-column databasesExpert · coming soon
- 70Graph databases and graph queryingExpert · coming soon
- 71Distributed SQL databasesExpert · coming soon
- 72Analytical databases and data warehousesExpert · coming soon
- 73Search engines and vector databasesExpert · coming soon
Reliability and senior judgment
- 74Database reliability engineeringExpert · coming soon
- 75Secure database engineeringExpert · coming soon
- 76Database migrations at scaleExpert · coming soon
- 77Database testing and correctnessExpert · coming soon
- 78Design reviews and trade-off analysisExpert · coming soon