Databases
Databases, gone deep: SQL, all six JOINs, advanced querying, indexes, transactions/isolation, and NoSQL. Includes the live SQL playground.
- chapters
- 7
- objectives
- 37
- core
- 23
- est. time
- 3h 24m
- 01 3.1 Relational model & SQL basics ★ core
Keys, SELECT/WHERE/ORDER BY from scratch, and GROUP BY with aggregates — plus the WHERE-vs-HAVING distinction. Practice it live in the playground.
- 02 3.2 JOINs ★ core
All six JOIN types, the difference between INNER and LEFT from memory, and the classic gotcha where a WHERE filter silently turns a LEFT JOIN into an INNER one.
- 03 3.3 Advanced querying
Subqueries (correlated vs not), CTEs for readability, and window functions (ROW_NUMBER/RANK/LAG/LEAD/running totals) vs GROUP BY.
- 04 3.4 Indexes & query performance ★ core
B-tree indexes, the composite-index leftmost-prefix rule, covering indexes, when indexes hurt, reading EXPLAIN, and the N+1 query problem.
- 05 3.5 Schema design & transactions ★ core
Normalization (1NF–BCNF) and when to denormalize, ACID, and the isolation levels with the exact anomaly each prevents (dirty / non-repeatable / phantom read).
- 06 3.6 NoSQL ★ core
The four NoSQL families and when each fits, BASE vs ACID, and sharding vs replication vs partitioning.
- 07 3.7 Stored routines, views & triggers
The database objects beyond tables: views and materialized views, stored procedures/functions, and triggers — plus UPSERT, full-text search, and JSON/JSONB. Logic and shapes that live in the database itself.
Section assessment
Harder, multi-concept questions drawn from across the module. Aim for 75%.
- 01hard
table_a has 3 rows; for a given a, b has 0, 1, 2 matches respectively. How many rows does `a LEFT JOIN b` produce?
- 02hard
Which lets you rank rows WITHOUT collapsing them into groups?
- 03hard
Given a composite index on (country, city, age), which queries can use it efficiently (leftmost-prefix rule)?
- 04hard
An ORM lazily loads each parent's children, firing 1 + N queries. This is the:
- 05hard
T1 reads a row; T2 updates+commits it; T1 re-reads and sees a different value. This anomaly is a:
- 06hard
Which isolation level prevents dirty reads but still allows non-repeatable reads?
- 07hard
Sharding primarily scales ___, while replication primarily scales ___.
- 08medium
Which aggregate ignores NULLs when counting a specific column, e.g. COUNT(col)?
- 09medium
You can reference a column alias defined in SELECT inside the WHERE clause.
- 10medium
You LEFT JOIN customers→orders and add `WHERE orders.status='shipped'`. Unexpectedly, customers with no orders disappear. Why?
- 11medium
To list employees alongside their manager (same table), you use a:
- 12medium
A CTE (WITH …) primarily improves: