cloudpatterns.appClassroomKatasWhiteboardBlog
Design Method & StylesChapter 16 · Draw it

Data model

Data model

The data model turns the API into entities, relationships and keys, then picks a store by how the data is read and written. In an interview, list the entities the endpoints touch, mark the one-to-many and many-to-many links, write down the hot queries, choose a relational or key-based store to fit them, and name the key or index each query uses — including which field would be the partition key once one machine isn't enough. Copy data into the shape of the hottest read when assembling it on every request would be too slow.

Use when
Right after the API — each endpoint's reads and writes become the list of access patterns · Choosing between a relational database and a key-based store · Naming the partition key before the scale deep dive
Avoid when
Drawing a full entity diagram with every column — the interview needs entities, keys and hot queries · Picking a database brand before listing the access patterns
Trade-offs
Relational gives flexible queries, joins and transactions, and scales writes only with sharding work · Key-based stores give fast, predictable reads for the queries their keys were built for, and are rigid for new ones · Copying data speeds the hot read and costs a write for every copy · Each index speeds a read and taxes every write
Requires
API design
3 objectives · 5 misconceptions
  • explain Explain how the API's resources become entities, attributes and relationships (one-to-many, many-to-many), and where each relationship lives as keys.
  • choose Choose a store — relational, a key-based NoSQL family, object storage for the bytes — from the access patterns and consistency needs, and justify it in one sentence.
  • predict Predict which key or index serves each hot query, which query would have to ask every shard, and when copying data for a hot read is worth the extra writes.
  • Not true: Pick NoSQL because relational databases don't scale.
  • Not true: Design the tables first; the queries will sort themselves out.
  • Not true: Store the photos in the database next to their rows.
  • Not true: A good model never stores the same fact twice.
  • Not true: The partition key is a detail to settle after launch.

Builds on

Contrast with

No close look-alikes.

Progress is saved on this device