# Exercise 1: Index Choice for a Product Catalog

## Scenario

You're advising the data team at `ShelfSpace`, a warehouse inventory platform. Their `products` table has 4 million rows and these query patterns from the application, each run thousands of times per day:

1. `SELECT * FROM products WHERE sku = ?` — exact SKU lookup (a fixed-format code like `"WH-4471-BLK"`), always a single exact match, never a range.
2. `SELECT * FROM products WHERE price BETWEEN ? AND ? ORDER BY price` — the storefront's price-filter/sort feature.
3. `SELECT * FROM products WHERE warehouse_id = ? ORDER BY restocked_at DESC LIMIT 20` — "recently restocked in this warehouse" dashboard widget.
4. `SELECT * FROM products WHERE discontinued = false` — a boolean flag; roughly 95% of the 4 million rows are `false`, 5% are `true`.

## Deliverables

Produce all of the following, in this file, below this line:

1. **A table of every query pattern above, the index you'd create for it (columns + order, and whether composite), and its structure (B-tree, or "none")** — for each, cite the specific theory section (this topic's or `01-database_indexes/`'s) that justifies your choice.
2. **For query 2 specifically**, explain in 2-3 sentences why a B-tree can serve `BETWEEN ... ORDER BY price` from a single index scan, referencing the leaf-node linking behavior from section 4.
3. **For query 4 specifically**, state whether you would index `discontinued` at all, and justify your answer using the low-cardinality reasoning from `01-database_indexes/` section 5 — the 95/5 split matters to your answer, explain why.
4. **One composite-index decision**: query 3 filters on `warehouse_id` and orders by `restocked_at`. Propose the composite index (column order matters — justify using `01-database_indexes/` section 4) that lets this query avoid a separate sort step entirely.

## Constraints

- Every index you propose must be justified by a specific query pattern above — no "just in case" indexes (theory section 5 of `01-database_indexes/` explicitly warns against this).
- Do not propose a hash index for query 2 — explain in one sentence why it couldn't serve that query at all (theory section 4).
