Section 1: Intro to SQL & The Declarative Shift
SQL solves three problems: writing queries declaratively, checking logic you did not write by hand, and running at cloud scale. This section covers each.
Three problems SQL solves
1. The "How vs. What" Problem (Declarative Logic)
Process a large dataset with hand-written loops and you re-implement filtering, joining, and aggregation yourself, and you tune the execution by hand.
-
The Problem: How do you extract complex insights without drowning in manual execution steps?
-
What SQL does: Declarative logic. You state what data you want; the query planner decides how to compute it (which scan, which join order). You do not write the execution steps.
2. Checking AI-generated queries
An LLM produces syntactically valid SQL quickly, but the logic is often wrong.
-
The Problem: How do you check that an AI-generated query returns the right rows, not just that it parses?
-
What SQL does: You need a mental model of query execution: trace JOIN behavior and use debug tables to verify generated code.
3. The Cloud Scale Problem
A 5 MB CSV fits in your laptop's memory. 50 TB of live user events does not, so the query runs across a cluster.
-
The Problem: How do you make the leap from local datasets to massive-scale infrastructure?
-
What SQL does: You'll learn to write queries for Cloud Data Warehouses like BigQuery, writing queries that run across a distributed cluster, where data layout and partition pruning decide cost.