Database Design & PostgreSQL
Database Design and PostgreSQL
Beyond basic SELECT: relational modeling, normalization, real PostgreSQL data types and schema implementation, advanced querying, transactions and concurrency, indexing, and operational safety.
Helpful before you begin (optional -- you can start this course now): Git, APIs & SQL
Who it's for
Developers who already know basic SQL (SELECT, JOIN, INSERT/UPDATE/DELETE, GROUP BY) and want to design real schemas, understand PostgreSQL-specific behavior, and operate a production database safely.
What you'll be able to do
- Model a domain into entities, relationships, cardinality, and optionality before writing any SQL
- Normalize a schema to Third Normal Form, and justify a deliberate denormalization tradeoff
- Implement a normalized PostgreSQL schema with correct types, constraints, and dependency-ordered DDL
- Write joins, subqueries, CTEs, and window functions, and explain PostgreSQL's transaction and isolation guarantees
- Add useful indexes, read EXPLAIN output, and design least-privileged roles
- Write ordered, safe schema migrations and describe a real backup/recovery plan
Not started — 14 lessons, no account required.
Start this coursePractice this course →Add to a study plan →Interview questions →
Relational modeling
Entities, attributes, relationships, keys, and constraints.
- 19 min
Relational Modeling: Entities, Attributes, and Relationships
Turning a real-world domain into entities, attributes, and relationships — and the cardinality/optionality questions that decide how those relationships are actually implemented.
- 20 min
Primary Keys, Foreign Keys, and Constraints
The identity guarantee a primary key provides, the referential-integrity guarantee a foreign key enforces, and the natural-vs-surrogate key decision every table forces you to make.
Normalized schema design
Functional dependencies, First through Third Normal Form, and denormalization tradeoffs.
- 21 min
Normalization: First and Second Normal Form
Functional dependencies as the underlying idea behind normalization, and the first two normal forms — eliminating repeating groups, then eliminating partial dependency on a composite key.
- 20 min
Third Normal Form and Denormalization Tradeoffs
Eliminating dependency on a non-key column, and the honest, deliberate cases where denormalizing a schema is the right engineering call, not a mistake.
PostgreSQL schema implementation
Real PostgreSQL data types, DDL, and dependency-ordered table creation and seed data.
- 20 min
PostgreSQL Data Types and DDL
Choosing the right PostgreSQL column type for a value — including the types SQLite doesn't distinguish at all — and the DDL that defines a table.
- 22 min
Implementing a Normalized Schema in PostgreSQL
Turning a relational model into real DDL with correctly-ordered CREATE TABLE statements, relationships, constraints, and seed data — and doing it for real, on your own machine.
Advanced querying
Multi-table joins and aggregation, subqueries and CTEs, and window functions.
- 20 min
Joins and Aggregation, Beyond the Basics
Going past the SELECT/JOIN/GROUP BY fundamentals from the SQL module: multi-table joins, HAVING vs. WHERE, and aggregate functions that hold up in both SQLite and PostgreSQL.
- 20 min
Subqueries and Common Table Expressions
Nesting a query inside another to answer a question a single flat query can't, and CTEs — the readable, nameable alternative for anything beyond a trivial subquery.
- 21 min
Window Functions: Calculations Across Rows Without Collapsing Them
The one capability GROUP BY fundamentally can't offer — a per-row calculation that sees other rows in its group without collapsing the result down to one row per group.
Transactions and performance
ACID guarantees, concurrent-update anomalies and isolation levels, and indexes and query plans.
- 20 min
Transactions and ACID Guarantees
Grouping several statements into one all-or-nothing unit, and the four ACID properties that make a transaction a genuine guarantee rather than a convention.
- 22 min
Concurrent-Update Problems and Isolation Levels
The specific anomalies that happen when two transactions overlap in time, and how PostgreSQL's isolation levels trade off which of those anomalies each one still permits.
- 22 min
Indexes, Composite Indexes, and Reading EXPLAIN
How an index turns an O(n) table scan into an O(log n) lookup, when adding one is actually the wrong call, and how to read EXPLAIN to find out instead of guessing.
Security and evolution
Views, roles and least privilege, and safe, ordered schema migrations.
- 20 min
Views, Roles, and the Principle of Least Privilege
Naming a reusable query as a view, and the security discipline of granting every role exactly the access it needs — never more.
- 23 min
Migrations, Schema Evolution, and Operational Safety
Changing a live schema safely with ordered, reversible migrations, testing database behavior deliberately, and the backup/recovery discipline that makes every other guarantee in this course matter.