SQL

Querying, writing and speeding up relational data.

SQL is taught here in 14 lessons, running from SELECT: reading data through to Next steps: analytics, data modelling and practice. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.

TrackDatabases
Lessons14
LevelBeginner to intermediate
Reading timeabout 3 hours
PrerequisitesNone beyond being able to open a text editor

Lessons

  1. SELECT: reading dataChoosing columns, filtering rows, sorting, and limiting — the shape of nearly every query you will write.
  2. JoinsINNER, LEFT, RIGHT and FULL joins explained with row counts — plus the accidental fan-out that ruins aggregates.
  3. Aggregation and GROUP BYCOUNT, SUM, AVG and friends; HAVING versus WHERE; and why COUNT(*) differs from COUNT(col).
  4. INSERT, UPDATE, DELETEChanging data safely: returning clauses, transactions, upserts, and the missing WHERE clause everybody learns once.
  5. Indexes and query speedHow indexes actually help, composite column order, and reading a query plan to find the real bottleneck.
  6. Data types, NULL and three-valued logicHow the common column types behave, why = NULL never matches anything, and the COALESCE, NULLIF and CAST tools that keep missing data from corrupting results.
  7. Subqueries, CTEs and window functionsScalar, correlated and derived subqueries, WITH and recursive CTEs, and the ROW_NUMBER/RANK/LAG family that ranks and compares rows without collapsing them.
  8. Constraints, keys and normalisationPrimary, foreign and unique keys, CHECK and defaults, referential actions, the first three normal forms, and when duplicating data on purpose is the right call.
  9. Creating and altering schema with DDLCREATE, ALTER and DROP, identity and generated columns, the safe way to change a busy table, temp tables, and which engines can roll DDL back.
  10. Views, functions, procedures and triggersSimple and materialised views, stored routines, triggers and their hidden cost, and how to decide which logic belongs in the database.
  11. Transactions and isolation levelsBEGIN, COMMIT and ROLLBACK, what ACID actually promises, the read phenomena isolation levels prevent, and how to recognise a deadlock before your users report it.
  12. Query tuning and execution plansHow to read EXPLAIN output, which scan and join strategies matter, why stale statistics ruin a plan, and how to write predicates an index can actually use.
  13. Portable SQL across database enginesWhat the standard actually guarantees, where PostgreSQL, MySQL, SQL Server and SQLite diverge, and the habits that keep a query movable.
  14. Next steps: analytics, data modelling and practiceAnalytical query patterns built from everything before, star schemas and slowly changing dimensions, and how to keep improving after the course ends.

More in Databases

MySQL PostgreSQL MongoDB Redis SQLite

FAQ

How long does the SQL course take?
It has 14 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for SQL?
No. This is the first course in Databases, so it starts from the beginning and assumes no background.
What should I read after SQL?
Continue with MySQL (14 lessons), the next course in Databases.