Backend development

Stage 2 of 7 · 11 lessons · ~3 months

Relational databases and SQL

Almost every backend is a careful wrapper around a relational database. Learn to model data, write SQL by hand, index it for real queries and understand what your ORM does on your behalf.

Start: Queries and joins

Lessons· one lesson for each topic, in this order

  1. 1Queries and joins
  2. 2Grouping and aggregates
  3. 3Data modelling and normalisation
  4. 4Keys, constraints and relationships
  5. 5Indexes
  6. 6Reading query plans with EXPLAIN
  7. 7Transactions and ACID
  8. 8Isolation levels and locking
  9. 9SQLx: pools and checked queries
  10. 10Schema migrations with sqlx-cli
  11. 11The N+1 query problem

Start with· follow one of these

Practise

Keep handy

  • Query macros, pools, transactions, migrations and offline mode, with PostgreSQL examples

Also worth your time

Before moving on: Design a PostgreSQL schema for a small booking or ordering system, write the ten queries it needs by hand, add indexes and show with EXPLAIN ANALYZE that they are used.

Tauseef's advice
Write raw SQL first; with SQLx you may never need an ORM, and the query macros keep your SQL checked against the real schema. Learn on PostgreSQL; it is the safest default and what most new projects pick.

Mark this stage as not done?