5. Choosing a data store
One-liner. Match the access pattern, not the brand.
Memorize
- Relational: transactions, joins, constraints — money, inventory, anything with invariants.
- Key-value / document: known access paths, huge scale, flexible schema — sessions, catalogs, profiles.
- Wide-column: time-series at write scale, predictable query keys.
- Search: full-text, relevance, facets — usually a derived index, not the source of truth.
- Blob: images, video, backups — object storage with a CDN in front.
- Warehouse/lake: analytics, not OLTP — scanning columns over billions of rows.
Trap. Using a search index as the primary database — no transactions, reindexing loses writes. Do this. Name the query you must serve fastest; pick the store that makes it a key lookup.
Check
An app needs multi-row transactions for order + payment + inventory, with strong consistency. Which store fits?
Why
Cross-entity invariants need ACID transactions and constraints; GSIs are eventually consistent and search/Redis are derived stores.