The relational mindset
SQL is the language for talking to relational databases — and it has quietly powered software for 50 years because the idea underneath it is so good. This lesson gives you the mental model everything else builds on.
The relational model in one picture
Data lives in tables: a grid of rows (records) and columns (fields). Every row in a table has the same columns; every column holds one type of value.
The magic is relationships: tables connect through shared values (an orders table stores a customer_id that points back to customers.id). You store each fact once and join tables together when you need them — no duplication.
Declarative, not step-by-step
SQL is declarative: you describe what you want, not how to get it. You don't write loops or index math — you state the result and the database's query planner figures out the fastest way to produce it.
-- "Give me the names of customers in Mumbai, newest first"
SELECT name
FROM customers
WHERE city = 'Mumbai'
ORDER BY created_at DESC;Compare that to the equivalent hand-written loop in a general-purpose language — SQL says the same thing in four readable lines, and runs it over millions of rows efficiently.
Why PostgreSQL
SQL is a standard, but every database adds its own extensions. This course uses PostgreSQL — the most capable open-source database, and the one CrackKit itself runs on. It's free, rock-solid, and has the richest feature set (JSONB, window functions, CTEs, full-text search). Almost everything you learn transfers to MySQL, SQLite, and others; where Postgres differs, we'll call it out.
The sample database
Every lesson uses one small e-commerce schema so examples build on each other:
- `customers` — id, name, city, created_at
- `products` — id, name, price, category
- `orders` — id, customer_id, status, total, created_at
- `order_items` — order_id, product_id, quantity
The relational mindset is the real skill here. Once you see data as tables linked by keys — and queries as descriptions of the result you want — SQL syntax becomes the easy part. That shift is what the rest of this section installs.