Tutorials

Eleven hands-on SQL workflows, from schema to Parquet analytics

Eleven self-contained tutorials. Tutorials 1–10 run live in the browser via WebAssembly. Tutorial 11 (Parquet) requires the native server.

Tutorial 1
Build a Task Tracker

Design a project-management schema with tasks, labels, and assignments. Covers SERIAL, foreign keys, CHECK constraints, ON CONFLICT upserts, and RETURNING.

CRUD CONSTRAINTS UPSERT RETURNING
Tutorial 2
Reporting Dashboard

Build a sales pipeline and slice it with aggregation, window functions, ROLLUP/CUBE, and reusable views. Rank reps, compute running totals, and generate subtotal rows.

GROUP BY WINDOW ROLLUP VIEWS
Tutorial 3
Time-Series Analytics

Model sensor readings with timestamps and intervals. Use DATE_TRUNC, EXTRACT, AGE, TO_CHAR, recursive CTEs to fill date gaps, and window frames for moving averages.

DATE/TIME INTERVAL CTE WINDOW FRAMES
Tutorial 4
Multi-Table Joins

An e-commerce schema with users, orders, items, and products. Walk through INNER, LEFT, RIGHT, FULL, CROSS, and NATURAL joins, plus correlated subqueries and EXISTS.

JOIN SUBQUERY EXISTS DERIVED TABLE
Tutorial 5
Schema Evolution

Start with a v1 schema and evolve it: add columns, rename fields, change types with CAST/::, and wrap migrations in transactions with nested BEGIN/COMMIT.

ALTER TABLE CAST TRANSACTIONS MIGRATION
Tutorial 6
Recursive CTEs & Tree Queries

Model an org chart with self-referencing foreign keys and query it with WITH RECURSIVE. Walk trees top-down and bottom-up, track depth, aggregate subtrees, and limit recursion depth.

WITH RECURSIVE HIERARCHY CTE SELF-JOIN
Tutorial 7
Set Operations & Data Comparison

Compare two warehouse inventories with UNION, UNION ALL, INTERSECT, and EXCEPT. Find shared products, exclusive items, and aggregate combined stock.

UNION INTERSECT EXCEPT SUBQUERY
Tutorial 8
String & Math Functions

Transform a product catalog with UPPER, SUBSTRING, REPLACE, CONCAT, ABS, ROUND, COALESCE, NULLIF, and CASE WHEN.

STRING MATH COALESCE CASE WHEN
Tutorial 9
Indexes & Query Performance

Create B-tree indexes, use EXPLAIN to see query plans, understand when indexes help and when they hurt. Covers IF NOT EXISTS, primary key indexes, and DROP INDEX.

CREATE INDEX EXPLAIN B-TREE PERFORMANCE
Tutorial 10
Sequences, Enums & Custom Types

Peek behind SERIAL to see sequences, create custom sequences with START/INCREMENT, and define ENUM types for fixed-set columns with ordinal ordering.

SEQUENCE SERIAL ENUM NEXTVAL
Tutorial 11
Parquet Foreign Tables

Map Parquet files to SQL tables with CREATE FOREIGN TABLE. Run joins, aggregates, subqueries, and CTEs across Parquet data. 9 benchmarked workloads on 50K–200K row files. Requires native server (not WASM).

PARQUET FOREIGN TABLE JOIN AGGREGATE