Part 3 of 5 · 2 min read
Matching the bookstore's own parts to a model
Different parts of one real system commonly have genuinely different access patterns, and so genuinely different best-fit models.
Think of a single restaurant with a walk-in freezer for bulk storage, a small countertop rack for today's fresh herbs, and a corkboard behind the counter for staff to pin take-out orders as they come in. One building, three different kinds of storage, each suited to what it holds.
In plain words: a real system is rarely just one access pattern repeated everywhere. The catalog, with its stable relationships and varied queries, fits relational. The shopping cart, looked up by one key only, fits key-value. The recommendation feature, which follows chains like "customers who follow an author who co-wrote with another author," fits graph, as covered two pages back. A high-volume event log of page views or order events, almost always appended and rarely queried except by a known key and time range, fits column-family, as covered on the previous page. Using more than one data model across one system, each for the part of the system it actually fits, is common practice, not a sign that one single choice was wrong.
A worked example. The bookstore runs its catalog and orders in a relational database, its shopping carts in a key-value store, its author-and-customer recommendation graph in a graph database, and its page-view event log in a column-family store. Each piece of data sits in the model that fits its own access pattern.
The key lines. No new SQL; this part is a system-level design decision spanning several of this level's earlier pages, not a single query.
Polyglot persistence
Polyglot persistence is using more than one kind of data store within a single system, with each store chosen to fit the access pattern of the specific data it holds, rather than forcing every kind of data through one single model.
Example: the bookstore running its catalog relationally, its carts as key-value, its recommendations as a graph, and its event log as column-family, all within one system, is polyglot persistence.