Honest Take — Before You Begin
You have written ActiveRecord queries for years. You know .where, .joins, .group, .having. You can chain scopes in your sleep. But I would bet real money you cannot write a WINDOW…
SQL Foundations & Relational Theory covers: Head First SQL, Learning SQL, Introduction to Database Systems. Build rock-solid SQL fundamentals beyond what ActiveRecord generates. Understand the relational model — sets, relations, normalization — so you can reason about database design from first principles instead of from Rails conventions.
ActiveRecord generates SQL. Reading EXPLAIN ANALYZE output is the single most valuable database skill for a Rails engineer. When you write User.where(active: true).order(:created_at).limit(10), ActiveRecord generates SELECT "users".* FROM "users" WHERE "users"."active" = TRUE ORDER BY "users"."created_at" ASC LIMIT 10. But what plan does PostgreSQL choose? Index scan or sequential scan? Does the index on active help or does the ORDER BY force a sort? After Module 0, you can answer these questions by reading the query plan, not by guessing.
You have written ActiveRecord queries for years. You know .where, .joins, .group, .having. You can chain scopes in your sleep. But I would bet real money you cannot write a WINDOW…
Open a console in your biggest Rails app and run .tosql on the chainiest scope you own — something with a joins, a group, maybe a having. Now close the console and try to write th…
Here's a requirement your product manager has definitely asked for: "show each customer's rank by total spend, within their region, alongside their spend last month." In ActiveRec…
Why can a subquery go almost anywhere a table can? Why does every scope you chain return something you can chain again? Why does SELECT DISTINCT even need to exist?
Work through each item before the checkpoint.
Twenty queries against a real seeded PostgreSQL database — joins, subqueries, window functions, recursive CTEs, set operations, and conditional aggregation — each written twice: o…
6 lessons. Read in order; spiral back when you need to. By the end you'll have used the core ideas twice — once on the abstract, once on something you'll meet at work next week.