TwiceToldby Develoker
ConceptsSystem designLabsCheat sheetsAbout

Develoker makes free tools for learning to build software. TwiceTold explains each idea twice, as an everyday analogy and the real thing; CloudArch lets you design cloud systems and put load on them.

About · Labs · Cheat sheets · Learning paths

← Back to NoSQL data models

🗄️ NoSQL data models: cheat sheet

🎨 The analogySwapping one big ruled ledger for storage furniture built for each job: pegs, filing cabinets, card catalogues.
🎓 The regular explanationThe four main non-relational data models (key-value, document, wide-column and graph), how each is modelled around its access patterns rather than normalised, and the trade-offs in joins, consistency and write cost that decide when to use one instead of a relational database.
From one ledger to storage furnitureStep 4 of 4
🧑‍💼Clerk📒 Shop ledgerfull🗄️ Cabinet, room 1🗄️ Cabinet, room 2🗄️ Cabinet, room 3
  1. The clerk writes Ana's order on the next line of the ledger. Every line has the same ruled columns, so it fits neatly.
  2. Now an order comes with a gift note, but there is no column for it. Every page has to be ruled again before anyone can write one.
  3. The shop gets busier and busier, and there is only one ledger. However fast the clerk writes, it can only be in one place.
  4. So the shop adds filing cabinets in three rooms. Each folder can hold whatever papers it needs, gift note included, and the work is shared between the rooms.
Four families, four kinds of questionStep 4 of 4
🧑‍💼Clerk🪝Coat-peg wall🗄️ Filing cabinet🗃️ Card catalogue📌 Photo corkboard
  1. At the coat-peg wall, the clerk just says a number and gets back whatever hangs on that peg. Nothing could be quicker, but the number is the only way to ask.
  2. At the filing cabinet, one folder holds everything about Ana, so one trip brings back her address and her orders together.
  3. At the card catalogue, Ana's drawer already keeps her cards in date order, so the cards since February come out in one neat handful.
  4. At the corkboard, the clerk follows the strings from Ana's photo to her friends, then to their friends.
Embed in the folder, or leave a slipStep 4 of 4
Ana's folder · growing forevero1key order 1: o11o2key order 2: o22o3key order 3, product id p7: o33o4key order 4: o4✦✦✦✦✦4o5key order 5: o5✦✦✦✦✦5o6key order 6: o6✦✦✦✦✦6Product foldersp7key teapot: p70p8key teacup: p8123🧑‍💼Clerk
  1. The clerk puts Ana's address and her first two orders straight into Ana's folder. The product folders already hold one copy of each product.
  2. When someone asks about Ana, one trip to the cabinet brings back everything, because it's all in one folder.
  3. The third order just has a slip saying see product folder 7. That keeps one copy of each product, but the clerk now makes a second trip.
  4. Every new order adds a page to Ana's folder, so it keeps getting thicker until it's too heavy to carry. Things that pile up without end deserve their own folders.
One drawer per questionStep 4 of 4
Ana's drawerJankey 2026-01-14, teapot: Jan0Febkey 2026-02-03, scarf: Feb1Markey 2026-03-09, scarf: Mar234Ben's drawer · cancelledFebkey 2026-02-20, teacup: Feb0Aprkey 2026-04-02, teapot: Apr1234Teapot drawer · out of stepAnakey Ana, 2026-01-14: Ana0Benkey Ben, 2026-04-02: Ben123🧑‍💼Clerk
  1. Each customer has a drawer in the card catalogue, and the cards inside stay in date order. Ana's new March order slots into her drawer in date order.
  2. The question this catalogue was built for, Ana's orders since February, opens one drawer and lifts out one neat handful of cards.
  3. But who bought the teapot would mean opening every drawer. So the shop adds a teapot drawer, and each teapot order is now written on two cards, one in each place. Ana's old teapot order is copied in too.
  4. Ben then cancels. The clerk fixes his drawer, but the trip to the teapot drawer goes wrong, and now the two cards disagree.
Waiting for one room, or for twoStep 4 of 4
Room 1 copy£5key teapot price: £50£6key teapot price: £61£7key teapot price: £7✦✦✦✦✦2Room 2 copy£5key teapot price: £5012Room 3 copy£5key teapot price: £50£6key teapot price: £61£7key teapot price: £7✦✦✦✦✦2🧑‍💼Clerk🙋Desk helper2 of 3 is enough
  1. The teapot card says £5 in all three rooms. The clerk changes it to £6 and only waits for one room to say done. The new card is still on its way to the other two rooms.
  2. Someone asks the price and is happy with one room's answer. The helper asks room 3, which still says £5. Quick, but out of date.
  3. This time they ask two rooms. Room 1 says £6 and room 3 says £5, so the helper picks the newer card and puts a fresh copy in room 3. To be sure every time, the clerk should wait for two rooms when filing too.
  4. Room 2 is locked. Waiting for two rooms still works, because rooms 1 and 3 answer. Waiting for all three would leave the clerk stuck.
The right furniture for each jobStep 5 of 5
🧑‍💼Clerk🪝Coat-peg wall📒 Shop ledger🗄️ Product cabineta moment behind📌 Photo corkboarda moment behind
  1. Ana's basket hangs on a coat peg. It changes often and only ever needs her peg number.
  2. The teapot's page comes from its folder in the product cabinet, with every detail in one place.
  3. For people who bought this also liked, the clerk follows the strings on the corkboard.
  4. Paying goes in the ledger, where the payment and the stock change are written together or not at all.
  5. The catch is that the cabinet and the corkboard must hear about the sale too. They're told just after, so for a moment they're a little behind.

🧩 Key questions

Every new order gets added to Ana's folder. What goes wrong after a few years?
The folder keeps getting thicker until it's slow and too heavy to carry, so orders should get their own folders. Keep together what you read together, but things that pile up without end get their own folders, with a slip back to Ana.
The shop wants to answer "who bought the teapot?" quickly, but the catalogue only has a drawer per customer. What does it do?
Add a drawer per product and write each order on two cards, one in each. Reading becomes one drawer again; the price is double the writing and keeping the copies in step.
The clerk only waits for one room to say done when filing, and someone then asks one room for the price. What can happen?
They may get the old price from a room the new card hasn't reached yet. Waiting for two rooms when filing and asking two rooms when reading means at least one always has the new card.
Payments must take money and update stock together, and the boss keeps asking new questions nobody planned for. Which piece of furniture fits best?
The ledger, with its strict columns and cross-references. The ledger writes things together or not at all, and its cross-references can answer questions nobody planned.