CSE Roadmap

Core tier · about 2 hours · 5 parts

Part 2 of 5 · 2 min read

The access-pattern question

The right model follows from how data is actually read and written, not from habit or from whichever database is already running.

Think of choosing a container for a kitchen. Flour goes in a wide, flat bin, easy to scoop from. Spices go in small, labeled jars, easy to grab one at a time. Neither container is wrong in general; each is wrong for the other's job.

In plain words: picking a data model starts with one question: how is this specific piece of data actually going to be read and written? A relational table fits data with stable, well-defined relationships queried in varied, ad-hoc ways. A document fits a self-contained record almost always read or written as a whole. A key-value store fits data always looked up by one exact key, with no need to query by its contents. A graph fits data that is mostly about its own connections, especially connections that keep growing new kinds. A column-family store fits data arriving as a high-volume, mostly-append stream, read back by a known key and a time range. The question is never "which database is best," but "which access pattern does this specific data have."

A worked example. The bookstore's catalog, queried in many different ways, by title, by author, by price range, fits the relational model's flexible, ad-hoc querying. The bookstore's shopping cart, always looked up by one customer ID and never searched by contents, fits the key-value model instead.

The key lines. No new SQL; this part is a decision framework, not a query.

Access pattern

An access pattern is how a specific piece of data is actually read and written in practice: by what key, how often, in what combinations, and whether it needs ad-hoc querying or only ever the same few lookups. It is the deciding factor in choosing a data model, more than habit or whichever database happens to already be running.

Example: the bookstore's catalog, queried by title, author and price in varied combinations, has a very different access pattern from its shopping cart, always looked up by one exact customer ID, and the two fit different models accordingly.