// LEARN · LANGUAGES & FRAMEWORKS
SQL
A practical SQL course on PostgreSQL, from creating a first table to tuning queries, securing data and keeping a database healthy. Every query is run and checked on PostgreSQL 18.
Level: Beginner to advanced · For: Developers, analysts and anyone who wants correct answers from a relational database. No experience needed.
Syllabus
Beginner
Complete
After this level you can
- Create tables with suitable types and constraints, and insert, update and delete rows
- Write SELECT queries with WHERE, ORDER BY, LIMIT, expressions and functions, and handle NULL correctly
- Join tables with inner and outer joins, summarise with aggregates, GROUP BY and HAVING, and predict the rows returned
- Use psql to connect, run scripts and inspect a schema
B1Getting started4 of 4 written · 4 lessonsBrowser and your computer
Create a database, tables and rows, and query them
You build: The library database
B2Querying one table5 of 5 written · 5 lessonsBrowser and your computer
Answer questions with filters, sorting, functions and correct NULL handling
You build: Answering ten questions about the library
B3Joins and aggregates6 of 6 written · 6 lessonsBrowser and your computer
Combine tables with joins and summarise data with aggregates, GROUP BY and HAVING
You build: A loans report
B4Changing data and schema5 of 5 written · 5 lessonsBrowser and your computer
Modify rows and evolve the schema safely with constraints and ALTER TABLE
You build: Evolving the library schema
Beginner project
Library database
A script that creates books, members and loans with keys and constraints, loads sample data and answers a set of questions with queries.
Runs in your browserSelf-checked against a rubric
Open the project guideIntermediate
Coming soon
After this level you can
- Choose and use PostgreSQL data types correctly: numeric, text, date and time with time zones, JSONB, arrays and ranges
- Write subqueries, CTEs including recursive ones, set operations and window functions
- Build views, materialized views, SQL and PL/pgSQL functions, and triggers
- Use transactions, explain isolation levels and MVCC, and write safe upserts
I1Data types in depthComing soon · 5 lessonsBrowser and your computer
Pick the right type and avoid type pitfalls with numbers, text, time zones and JSONB
You build: An event-log schema with arrays and ranges
- I1.1Coming soon
- I1.2Coming soon
- I1.3Coming soon
- I1.4Coming soon
- I1.5Coming soon
I2Advanced queriesComing soon · 6 lessonsBrowser and your computer
Write multi-step queries and rankings with subqueries, CTEs, set operations and window functions
You build: A leaderboard with running totals
- I2.1Coming soon
- I2.2Coming soon
- I2.3Coming soon
- I2.4Coming soon
- I2.5Coming soon
- I2.6Coming soon
I3Views, functions and triggersComing soon · 5 lessonsBrowser and your computer
Put reusable logic into the database with views, functions and triggers
You build: An audit-log trigger
- I3.1Coming soon
- I3.2Coming soon
- I3.3Coming soon
- I3.4Coming soon
- I3.5Coming soon
I4Transactions and concurrencyComing soon · 5 lessonsRuns on your computer
Keep data correct when many sessions write at once
You build: A safe money transfer
- I4.1Coming soon
- I4.2Coming soon
- I4.3Coming soon
- I4.4Coming soon
- I4.5Coming soon
Intermediate project
Shop analytics
Monthly revenue and top customers per month with window functions, a materialized view for a dashboard and an audit trigger on orders.
Runs on your computerSelf-checked against a rubric
Advanced
Coming soon
After this level you can
- Read EXPLAIN ANALYZE output, choose multicolumn, partial and expression indexes, and load data efficiently with COPY
- Design a normalised schema with keys, constraints, generated columns, schemas and partitioning
- Secure a database with roles, privileges and row-level security, prevent SQL injection, and back up and restore
- Implement full-text search and JSON path queries, and maintain a database with VACUUM and statistics views
A1Indexes and query performanceComing soon · 6 lessonsRuns on your computer
Find slow queries with EXPLAIN and make them fast with the right indexes
You build: Speeding up five slow queries
- A1.1Coming soon
- A1.2Coming soon
- A1.3Coming soon
- A1.4Coming soon
- A1.5Coming soon
- A1.6Coming soon
A2Schema designComing soon · 4 lessonsBrowser and your computer
Design a schema that keeps data consistent
You build: Designing the shop schema
- A2.1Coming soon
- A2.2Coming soon
- A2.3Coming soon
- A2.4Coming soon
A3Security and administrationComing soon · 5 lessonsRuns on your computer
Control access with roles and row-level security, and recover from mistakes with backups
You build: Multi-tenant data with row-level security
- A3.1Coming soon
- A3.2Coming soon
- A3.3Coming soon
- A3.4Coming soon
- A3.5Coming soon
A4Search, JSON and maintenanceComing soon · 4 lessonsRuns on your computer
Add full-text search and keep a database healthy
You build: Book search with ranking
- A4.1Coming soon
- A4.2Coming soon
- A4.3Coming soon
- A4.4Coming soon
Advanced project
Tuned, secured shop
The shop database with a larger dataset, indexes chosen from EXPLAIN ANALYZE evidence, tenant isolation with row-level security and a tested backup and restore.
Runs on your computerSelf-checked against a rubric
Capstone
Capstone
Booking system database
A schema whose constraints prevent double booking, functions for the booking workflow, reports, roles, search and a portfolio README.
Runs on your computerSelf-checked against a rubric
Sources
- PostgreSQL 18 documentation
- PostgreSQL Downloads (postgresql.org)
- Windows installers (postgresql.org)
- Architectural Fundamentals (PostgreSQL 18 documentation, tutorial)
- Creating a Database (PostgreSQL 18 documentation, tutorial)
- Accessing a Database (PostgreSQL 18 documentation, tutorial)
- Creating a New Table (PostgreSQL 18 documentation, tutorial)
- Populating a Table With Rows (PostgreSQL 18 documentation, tutorial)
- psql (PostgreSQL 18 documentation, client applications)
- Lexical Structure: operator precedence (PostgreSQL 18 documentation, SQL syntax)
- Numeric Types (PostgreSQL 18 documentation, data types)
- Character Types (PostgreSQL 18 documentation, data types)
- Date/Time Types (PostgreSQL 18 documentation, data types)
- Boolean Type (PostgreSQL 18 documentation, data types)
- CREATE TABLE (PostgreSQL 18 documentation, SQL commands)
- DROP TABLE (PostgreSQL 18 documentation, SQL commands)
- Inserting Data (PostgreSQL 18 documentation, data manipulation)
- INSERT (PostgreSQL 18 documentation, SQL commands)
- Default Values (PostgreSQL 18 documentation, data definition)
- Querying a Table (PostgreSQL 18 documentation, tutorial)
- Aggregate Functions: count and max (PostgreSQL 18 documentation, functions)
- Select Lists: column labels (PostgreSQL 18 documentation, queries)
- Table Expressions: joins and GROUP BY (PostgreSQL 18 documentation, queries)
- Comparison Functions and Operators (PostgreSQL 18 documentation)
- Logical Operators (PostgreSQL 18 documentation, functions)
- Row and Array Comparisons: NOT IN (PostgreSQL 18 documentation, functions)
- Sorting Rows (ORDER BY) (PostgreSQL 18 documentation, queries)
- LIMIT and OFFSET (PostgreSQL 18 documentation, queries)
- SELECT: output column names (PostgreSQL 18 documentation, SQL commands)
- Mathematical Functions and Operators (PostgreSQL 18 documentation, functions)
- Value Expressions: Aggregate Expressions (PostgreSQL 18 documentation, SQL syntax)
- String Functions and Operators: concat (PostgreSQL 18 documentation, functions)
- Pattern Matching: LIKE (PostgreSQL 18 documentation, functions)
- Conditional Expressions: CASE (PostgreSQL 18 documentation, functions)
- Joins Between Tables (PostgreSQL 18 documentation, tutorial)
- Aggregate Functions (PostgreSQL 18 documentation, tutorial)
- Updating Data (PostgreSQL 18 documentation, data manipulation)
- Deleting Data (PostgreSQL 18 documentation, data manipulation)
- UPDATE (PostgreSQL 18 documentation, SQL commands)
- DELETE (PostgreSQL 18 documentation, SQL commands)
- TRUNCATE (PostgreSQL 18 documentation, SQL commands)
- Returning Data from Modified Rows (PostgreSQL 18 documentation, data manipulation)
- Release 18 (PostgreSQL 18 documentation, release notes)
- Constraints (PostgreSQL 18 documentation, data definition)
- Foreign Keys (PostgreSQL 18 documentation, tutorial)
- Modifying Tables (PostgreSQL 18 documentation, data definition)
- ALTER TABLE (PostgreSQL 18 documentation, SQL commands)
- Identity Columns (PostgreSQL 18 documentation, data definition)