SQL & Databases

From first query to production PostgreSQL

Master SQL through practical, step-by-step lessons. Start with SQLite for zero-friction learning, then graduate to PostgreSQL via Docker. Query a realistic e-commerce database from your first SELECT to window functions, CTEs, and production DevOps workflows.

5 modules
19 lessons
221 steps
455 min total
First Step

Download the SQL setup files from GitHub before Lesson 1. This prevents the first-run setup confusion and gives you the exact files the lesson expects.

Setup Checklist

Modules 1-3 use SQLite (zero setup on Mac/Linux). Module 4 introduces PostgreSQL via Docker.

  • βœ”SQLite installed (pre-installed on macOS and most Linux)
  • βœ”Download both SQL setup files using the resource card above before starting Lesson 1
  • βœ”Docker installed for Module 4 (PostgreSQL lessons)
Time & Flow
  • Write your first SELECT in under 5 minutes
  • Query a realistic e-commerce database throughout
  • SQLite first (Modules 1-3), PostgreSQL later (Module 4)
Learner Guardrails
  • Ask β€œone row per what?” before every JOIN or GROUP BY
  • Modules 1-3 use SQLite, Module 4 switches to PostgreSQL, and Lesson 501 is a separate capstone schema
  • For datetime filters, prefer `>= start` and `< next_day` over brittle end dates
Ideal Fit
  • DevOps engineers who query databases during incidents
  • Backend developers wanting deeper SQL fluency
  • Anyone who works with data and wants to go beyond basic SELECT

Learning Path

Progress through these modules to master SQL. Click any module to expand and view lessons.

5 modules β€’ 1 open

1

201 β€” Aggregation and Grouping

Learn to summarize data with aggregate functions and GROUP BY. Transform thousands of rows into meaningful totals, averages, and counts β€” the foundation of every business report.

Intermediate20 minutes12 steps
Required
Lesson 104 complete
2

202 β€” Joining Tables

Connect related tables to build complete pictures of your data. Joins are the most powerful tool in SQL β€” they let you answer questions that span multiple tables, like 'what did each customer order and how much did they spend?'

Intermediate25 minutes14 steps
Required
Lesson 201 complete
3

203 β€” Subqueries

Nest one query inside another to answer complex questions in a single statement. Subqueries let you filter, compare, and derive data dynamically β€” no hardcoded values needed.

Intermediate20 minutes10 steps
Required
Lesson 202 complete
4

204 β€” Advanced Expressions and Set Operations

Master CASE WHEN for conditional logic, handle NULLs gracefully with COALESCE, manipulate strings and dates, and combine result sets with UNION and friends. This lesson uses SQLite-flavored functions and emphasizes how result grain changes when you group or stack results.

Intermediate20 minutes12 steps
Required
Lesson 203 complete
5

205 β€” Checkpoint: Build a Sales Report

Put all your Module 2 skills to the test by building a comprehensive sales report from scratch. No new concepts β€” just pure practice combining JOINs, aggregation, subqueries, CASE WHEN, and everything else you've learned, with explicit attention to result grain.

Intermediate15 minutes8 steps
Required
Lesson 204 complete
1

401 β€” Database Design and Normalization

Learn to design relational databases from scratch in a separate SQLite design lab. Understand normalization forms (1NF, 2NF, 3NF), entity relationships, junction tables, and when to break the rules and denormalize for performance.

Advanced25 minutes12 steps
Required
Lesson 304 complete
2

402 β€” PostgreSQL Setup via Docker

Launch a production-grade PostgreSQL 16 database in Docker, connect with psql, and verify that everything you learned in Modules 1-3 transfers directly. This lesson bridges your SQLite knowledge to the database used in real-world DevOps. Module 4 uses a compact teaching schema; the larger Lesson 501 capstone later introduces a separate analytics schema on a separate container.

Advanced15 minutes8 steps
Required
Lesson 401 completeDocker installed (see Docker track)
3

403 β€” PostgreSQL-Specific Features

Unlock the power tools that set PostgreSQL apart: JSONB for semi-structured data, arrays, UUID generation, schemas for organization, import/export with COPY, and identity columns. This lesson is fully PostgreSQL-specific and continues the compact Module 4 schema in the Docker container.

Advanced25 minutes12 steps
Required
Lesson 402 complete
4

404 β€” SQL for DevOps

Apply SQL skills to real DevOps operations in PostgreSQL: write database migrations, monitor health, analyze query performance, back up and restore databases, and build operational dashboards. These are the queries you'll run at 3 AM during incidents.

Advanced25 minutes12 steps
Required
Lesson 403 complete
5

405 β€” Performance Tuning and Security

Master the two pillars of production databases: making queries fast with EXPLAIN ANALYZE, query plans, and indexing strategies, and keeping data safe with SQL injection prevention, parameterized queries, role-based access control, and row-level security. This lesson continues the compact PostgreSQL schema you created in Lessons 402-404 inside the `pg-sql-course` container.

Advanced25 minutes12 steps
Required
Lesson 404 complete

Ready to Master SQL?

Work through these lessons at your own pace. Each step includes commands, explanations, and expected outcomes.