Access patterns before technology
Describe each dataset before choosing a store: its reads and writes with their shapes, peak rates, item sizes and their spread, growth and retention, invariants and staleness budgets, and the recovery it needs.
Contentsand lesson path
On this page
- Why it matters
- Describe the dataset, not the database
- Name the shape of each read
- Size, rate and growth in numbers
- Consistency: name the rule and the staleness budget
- Check your understanding
- Apply it
- Review prompt
Lessons of Data Store Selection
- Access patterns before technology Concept · 15 min
- Store families and what each is good at Concept · 25 min
- Sanity-checking a store choice at target scale Worked example · 25 min
- Blobs in object storage, metadata in a database Concept · 15 min
- Choosing stores for a marketplace Lab · 25 min
- Data store selection check Knowledge check · 8 questions
What you will learn
- Characterize a dataset by access pattern, size, growth, consistency and query needs.
01. Why it matters
Many teams pick the database first and describe the data later: "we already use PostgreSQL", "MongoDB is flexible", "Cassandra scales". The pick then shapes every query, every migration and many outages for years. A safer order is to describe each dataset first, then ask which store serves that description well. A dataset here means a set of records with one owner and one purpose, such as parcels, scan events or uploaded photos.
This lesson gives you a short, repeatable way to write that description, called a dataset card. Lesson 2 matches cards to store families, lesson 3 checks a choice against target scale, lesson 4 handles large files, and the lab applies all of it to a marketplace.
The running example is a regional parcel-delivery service. Shops create parcels, scanners in depots record every movement, couriers photograph each delivery, and customers follow their parcel on a public tracking page. That gives four datasets: parcels, scan events, delivery photos and depot dashboard statistics.
02. Describe the dataset, not the database
A dataset card answers the questions that separate one store from another. Write it in the language of the application, not of any product:
- Operations. Every write and every read, as a sentence with its key, filter and sort order: "all scans of one parcel, oldest first". Give each read an id (R1, R2…) and the latency it needs.
- Rates. Reads and writes per second at the busiest hour, not per day. Daily totals hide the peak that sizes the system.
- Size. Bytes per item and the number of items, with the spread: the median and the largest item, not only the average.
- Growth and retention. How fast the dataset grows, and how long data stays online before it is archived or deleted.
- Consistency. The invariants that must always hold, and how stale each read may be.
- Query flexibility. Whether every query is known in advance, or people will ask new questions next month.
- Recovery. How much recent data you may lose in a failure (the recovery point objective, RPO) and how soon service must be back (the recovery time objective, RTO).
Dataset card: scan_events owner: depot systems team
Writes one row per scan, never updated; 16 M a day, about 560/s at peak
Reads R1 all scans of one parcel, oldest first tracking page, p99 < 100 ms
R2 scans at one depot, last 15 minutes depot screen, every 30 s
R3 scans per depot per hour, last 90 days weekly report, ad hoc
Size about 100 B per row with indexes (first guess; lesson 3 measures it)
Growth +35% a year; 400 days online, then exported to the archive
Consistency R1 may lag a write by 5 s; R2 by 30 s; R3 by one day
Invariants a scan is stored once, even when the scanner retries (event id)
Recovery lose at most 1 minute of scans (RPO); back within 4 hours (RTO)Notice what the card does not say: nothing about tables, documents, SQL or NoSQL. Each line is a fact or an assumption that someone can check. "About 100 B per row" is marked as a first guess, because guesses that drive a decision must be measured later.
03. Name the shape of each read
Stores differ most in which shapes of read they serve cheaply. Almost every read falls into one of these:
- Point lookup by key: one item by its id, such as a parcel by tracking number.
- Range within a key: items stored under one key and sorted, such as the scans of one parcel in time order (R1).
- Lookup by another attribute: items found by a field that is not the key, such as recent scans at one depot (R2). This needs a secondary index or a second copy organised by that field.
- Text search with relevance: words, typos and ranking, such as "blue sofa" matching "Blue velvet sofa".
- Aggregation over many rows: counts and sums across a large slice of the data, such as scans per depot per hour over 90 days (R3).
- Relationship traversal: following links several steps, such as "accounts that share a card with accounts that share an address with this one".
- Whole-object read: a large file fetched by its key, such as one delivery photo.
One dataset often has several shapes. The scan events card has a range within a key (R1), a lookup by another attribute (R2) and an aggregation (R3). When shapes pull in different directions, a common answer is one primary copy plus derived copies: an hourly summary table for R3, for example. Every derived copy costs a sync job and adds a delay, so the card must say how much delay each read accepts.
04. Size, rate and growth in numbers
Put numbers on the cards before you compare stores. The script below holds the year-one assumptions for all four datasets and prints peak rates, daily volume and the size kept online after retention. Save it as dataset_cards.py; it needs only Python 3.12.
"""Volume, rate and growth for four datasets of a parcel service (Python 3.12)."""
DAY_S = 86_400
MB, TB = 10**6, 10**12
PEAK_FACTOR = 3.0 # busiest hour / average hour, from depot shift patterns
# Year-one assumptions. "writes_per_item" counts the insert plus later updates.
DATASETS = {
"parcels": {"new_per_day": 2_000_000, "writes_per_item": 9,
"bytes_per_item": 1_500, "reads_per_day": 24_000_000,
"online_days": 730},
"scan_events": {"new_per_day": 16_000_000, "writes_per_item": 1,
"bytes_per_item": 100, "reads_per_day": 4_000_000,
"online_days": 400},
"delivery_photos": {"new_per_day": 1_400_000, "writes_per_item": 1,
"bytes_per_item": 400_000, "reads_per_day": 30_000,
"online_days": 730},
"depot_stats": {"new_per_day": 17_280, "writes_per_item": 1,
"bytes_per_item": 200, "reads_per_day": 60_000,
"online_days": 90},
}
print(f"{'dataset':<16}{'peak writes/s':>14}{'peak reads/s':>13}{'reads:writes':>13}"
f"{'MB/day':>10}{'online':>10}")
for name, d in DATASETS.items():
writes_day = d["new_per_day"] * d["writes_per_item"]
mb_day = d["new_per_day"] * d["bytes_per_item"] / MB
online_tb = mb_day * MB * d["online_days"] / TB
online = f"{online_tb:.1f} TB" if online_tb >= 1 else f"{online_tb * 1000:.1f} GB"
print(f"{name:<16}{writes_day / DAY_S * PEAK_FACTOR:>14,.0f}"
f"{d['reads_per_day'] / DAY_S * PEAK_FACTOR:>13,.0f}"
f"{d['reads_per_day'] / writes_day:>13.2f}{mb_day:>10,.1f}{online:>10}")python3.12 dataset_cards.pydataset peak writes/s peak reads/s reads:writes MB/day online
parcels 625 833 1.33 3,000.0 2.2 TB
scan_events 556 139 0.25 1,600.0 640.0 GB
delivery_photos 49 1 0.02 560,000.0 408.8 TB
depot_stats 1 2 3.47 3.5 0.3 GBThe four datasets differ by orders of magnitude, and in different directions:
- Parcels take the most reads (833/s at peak) and are updated about eight times after they are created, so they need fast lookups by key and updates in place.
- Scan events are written far more than they are read (0.25 reads per write) and are never updated: an append-only stream.
- Delivery photos are only 49 writes per second, but 560,000 MB a day, about 99% of all bytes, and are almost never read. Large, write-once, rarely read files are a different problem from records; lesson 4 deals with them.
- Depot statistics are tiny. Almost any store would do, so the one you already run is the obvious candidate.
Two cautions about size. First, a row costs more than its column values: databases add a header to every row, align values in memory-friendly steps, and store an entry per row in every index. Lesson 3 measures this, and for small rows it can double the size. Second, record the largest item as well as the average. Per-item limits apply to the largest one: for example 400 KB per item in Amazon DynamoDB and 16 MiB per document in MongoDB, as their documentation stated in November 2026.
05. Consistency: name the rule and the staleness budget
"The data must be consistent" is too vague to choose a store with. Write two more precise things instead.
The first is the list of invariants: rules that must hold after every write, such as "a parcel is delivered at most once" or "a scan is stored once even if the scanner sends it twice". For each invariant, note how many records it touches. A rule inside one record can be protected by a conditional update of that record, which almost every store supports. A rule that spans several records needs a transaction across them, or a data model that keeps those records together where the store can update them atomically. That single fact rules some stores in or out.
The second is a staleness budget for each read: the oldest data it may show. The courier app that has just marked a parcel delivered must see its own write. The tracking page can be a few seconds behind, and the weekly report a day behind. Reads with a budget of seconds or more can be served from replicas, caches, search indexes or analytics copies, which all lag the primary copy by design. A blanket rule of "strong consistency everywhere" closes those options without making the important reads any safer. How to give one user their own writes back (read from the primary, wait for a replica to catch up, or track a session token) is a separate design choice, covered in Database Scaling.
06. Check your understanding
07. Apply it
Start the practice task of this skill: a marketplace with listings, orders, chat, product images, search and click analytics. Write one dataset card for each of these six datasets, using the fields above:
- Operations as sentences with ids, each with its shape and latency target.
- Peak reads and writes per second, item size with median and largest, growth and retention.
- Invariants with the number of records each touches, and a staleness budget per read.
- RPO and RTO.
Mark every guess as a guess. Keep the cards: lesson 2 adds a store to each, lesson 3 checks the two busiest at target scale, and the lab tests several of them against real stores.
08. Review prompt
Without looking back, answer in your own words:
- Which fields belong on a dataset card, and why does none of them name a product?
- Name five shapes of read and give an example of each from an app you use.
- Why can an average item size mislead you, in two different ways?
- What is the difference between an invariant and a staleness budget, and how does each narrow the choice of store?
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.