Skip to content
Pebellslearn by building

The course

SQL

Learn how relational databases think and how to talk to them in SQL. You will create tables, add and change rows, summarise data with aggregates, and protect it with constraints — all on one small shop database.

Ready to learn

Your path through the ideas

Inside the course

7 modules · 23 lessons
CLI tools & setup · Start here

Install your tools, choose your setup and verify a local run.

02Learn the Basics3 lessons

A relational database organizes records in tables and relates them through keys. SQL is a language for querying and changing that data. Meet tables, rows, columns and keys through a small shop database, weigh what relational systems are good and bad at, and see where NoSQL stores fit instead.

  1. 01What Is a Relational Database?12 min
  2. 02RDBMS Benefits and Limitations12 min
  3. 03SQL vs NoSQL Databases12 min
03Basic SQL Syntax4 lessons

SQL syntax defines how keywords, identifiers, values and operators form a valid statement. Learn how a statement is put together from keywords, pick sensible data types, combine conditions with operators, and ask your first real questions with SELECT.

  1. 01SQL Keywords and the Shape of a Statement12 min
  2. 02Data Types15 min
  3. 03Operators15 min
  4. 04SELECT — Asking for Data15 min
04Data Definition Language (DDL)4 lessons

Data Definition Language, or DDL, consists of statements that create, change or remove database structures such as tables. Build the shop's tables with CREATE TABLE, change them safely with ALTER TABLE, and learn exactly how TRUNCATE and DROP differ before you ever run them on real data.

  1. 01CREATE TABLE15 min
  2. 02ALTER TABLE15 min
  3. 03TRUNCATE TABLE12 min
  4. 04DROP TABLE12 min
05Data Manipulation Language (DML)3 lessons

Data Manipulation Language, or DML, consists of statements that add, change or remove stored rows. Put data into the shop with INSERT, change it with UPDATE and remove it with DELETE, using one habit — preview with SELECT first — that keeps every change deliberate.

  1. 01INSERT — Adding Rows15 min
  2. 02UPDATE — Changing Rows15 min
  3. 03DELETE — Removing Rows15 min
06Aggregate Queries5 lessons

An aggregate query combines multiple input rows into summary values, optionally producing a separate summary for each group. Count, total, average and find extremes with COUNT, SUM, AVG, MIN and MAX, then answer 'per customer' and 'more than' questions with GROUP BY and HAVING.

  1. 01COUNT — How Many?12 min
  2. 02SUM and AVG — Totals and Averages15 min
  3. 03MIN and MAX — Smallest and Largest12 min
  4. 04GROUP BY — One Answer per Group15 min
  5. 05HAVING — Filtering Groups15 min
07Data Constraints4 lessons

A constraint is a database rule that restricts which rows or relationships may be stored. Give every row an identity with primary keys, link tables safely with foreign keys, and write business rules into the schema with UNIQUE, NOT NULL and CHECK.

  1. 01Primary Key15 min
  2. 02Foreign Key15 min
  3. 03UNIQUE and NOT NULL12 min
  4. 04CHECK15 min
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.