Firman Hanafi
Solution Architect · Notes

0 to Hero SQL

A roadmap through SQL, from a first SELECT to isolation levels and query plans — written against PostgreSQL and MySQL side by side, because the two disagree exactly where it costs you.

mixed10 lessons3h 7m totalAugust 2026EN · ID

What you'll learn

  • Read and write everyday SQL without guessing what the engine will do with it
  • Reason about NULL correctly, including the comparisons that quietly return nothing
  • Choose the right join, and recognise the accidental cross join before it runs
  • Replace a nested subquery with a CTE or a window function when that is the clearer tool
  • Design a schema whose constraints make the wrong row impossible to insert
  • Read EXPLAIN on both engines and say why an index was not used
  • Pick an isolation level deliberately, and explain the anomaly it still allows
  • Write the production patterns — upsert, keyset pagination, an online migration — for both engines

Course content

4 sections10 lessons3h 7m total

Foundations3 lessons · 48m
  1. The relational model, and your first queries16m
  2. NULL, and why your filter returned nothing14m
  3. Grouping and aggregation, without double counting18mQuiz: sql-0-to-hero-basics
Joins and shaping3 lessons · 55m
  1. Joins that hold up18m
  2. Subqueries, CTEs and set operations17m
  3. Window functions20mQuiz: sql-0-to-hero-intermediate
Design2 lessons · 42m
  1. Schema design and constraints20m
  2. Indexes and query plans22m
Production2 lessons · 42m
  1. Transactions and isolation20m
  2. Production patterns22mQuiz: sql-0-to-hero-advanced

Requirements

  • PostgreSQL 14+ or MySQL 8.0+, locally or in Docker
  • Willingness to run the queries rather than read them

A terminal and one of the two databases installed. No prior SQL. Lesson 8 onwards assumes you have written queries against a table with real rows in it.

Description

Most SQL material teaches one dialect and lets you discover the rest during an incident. This roadmap uses PostgreSQL and MySQL together, and every lesson that has a difference says so in a table rather than a footnote — because the places they diverge are not trivia. The default isolation level is different. One has FULL OUTER JOIN and the other does not. GROUP BY is strict in one and, depending on how the server was configured, forgiving in the other. Those are the things that turn a query that worked in staging into a bug report.

How the roadmap is ordered

Four stages, and they build:

  1. Foundations — the relational model, SELECT, and the two things beginners get wrong first: NULL and GROUP BY.
  2. Joins and shaping — joins, subqueries, CTEs, then window functions, which are what you reach for once you stop trying to do it all with GROUP BY.
  3. Design — schema, constraints and types, then indexes and reading a query plan. This is where SQL stops being a language and starts being a system.
  4. Production — transactions and isolation, then the patterns you need on a live database: upserts, pagination that survives page 500, migrations that do not lock a table for ten minutes.

Nothing here is gated. Reading is free and always will be; you sign in only if you want the progress marks and the quiz results to belong to you.

The quizzes

There is one quiz per stage, not one per lesson, and that is deliberate: the interesting questions cross lessons. Each is 20 questions and tells you your score without telling you which ones you got wrong — you get a topic to go back to instead of an answer to memorise.

If you want a quick calibration first, the standalone SQL Basics quiz is a reasonable entry test. Score badly on it and start at lesson 1; score well and you can probably begin at lesson 4.

Who this is for

  • Engineers who use an ORM and want to know what it is generating
  • Anyone who has written SQL that worked on a small table and fell over on a large one
  • Backend developers who have never been shown EXPLAIN