SQL
CivicGrid's data lives in Postgres, and most of my data rules are really SQL rules: write by a stable key, dry-run first, keep a backup, check the invariants afterwards.
Learning track · 13 lessons
SQL with Postgres
Hands-on with Postgres in a Docker container, on a made-up Larkspur County database of towns, leaders and meetings. Each lesson explains one idea, has you try it on data whose right answers are known, then shows how CivicGrid uses it, including where it went wrong.
- 1What a database is, and why SQLComing soon
- 2Your first database: Postgres and psqlComing soon
- 3Asking questions: SELECT, WHERE and ORDER BYComing soon
- 4Counting and groupingComing soon
- 5Joining tablesComing soon
- 6Designing tables: keys, types and constraintsComing soon
- 7Changing data safelyComing soon
- 8NULL, and the other trapsComing soon
- 9Indexes, and reading EXPLAINComing soon
- 10Checks as queriesComing soon
- 11Who can see what: roles and row-level securityComing soon
- 12SQL from code, and SQL injectionComing soon
- 13Backups, and restoring themComing soon
Tools I use
PostgreSQL documentation (opens in a new tab)
The official manual. The tutorial chapter is a good first read.
SQLBolt (opens in a new tab)
Short interactive lessons that run in the browser.
PostgreSQL Exercises (opens in a new tab)
Practice questions on one sample database, from simple to hard.
From www.kwamib.dev/resources/sql