Key-Value and Document Stores · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

One key in, whole thing back

Computing · Data & Databases · ages 20-21
Name ______________________   Date ____________
  1. For var cat = { name: "Mittens", age: 5 }, what does cat.name give?

    • 5
    • gray
    • Mittens
  2. You hand a key-value store one key. What comes back?

    • The whole value stored under that key
    • A join of several tables
    • A report on the data shape
  3. A key-value store checks the shape of your data and joins tables for you.

    Circle one:   True   False

  4. Which question does a document design answer badly?

    • Show one post with all its comments
    • The average age of all cats in every city
    • Fetch the profile stored under one key
  5. Every cat record repeats its owner city, and the owner moves. What must happen?

    • Every copy must be updated, or copies will disagree
    • Nothing, the copies fix themselves
    • Only one copy needs the new city
  6. A cat record holds a nested owner object with name and city. Why is the read fast?

    • The database joins two tables at read time
    • The city is stored on a faster disk
    • The whole nested thing sits together, so one lookup returns everything
  7. A friend stores the city in every record for speed, then says updates are free too. What is the flaw?

    • Duplication buys read speed but charges work and risk on every update
    • Reads become slower with duplication
    • Cities can never be stored in records
  8. Readers open one blog post with its comments at a time. Which design fits, and why?

    • Normalised tables, to slow down single reads
    • One document per post with nested comments, for fast single-thing reads
    • No storage at all, to keep things simple
LightMySky · lightmysky.comW1-mt_PfBDSgfeQX-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

One key in, whole thing back W1-mt_PfBDSgfeQX-s1

  1. Mittens · You reach a value through its key, so the name key gives Mittens.
  2. The whole value stored under that key · One key in, whole value back, with no checks and no joins.
  3. False · It does neither: it stores what you give and returns whole values by key.
  4. The average age of all cats in every city · Cross-cutting questions need joins and a schema, which documents gave up.
  5. Every copy must be updated, or copies will disagree · Duplication charges work and risk on every update: miss a copy and data disagrees.
  6. The whole nested thing sits together, so one lookup returns everything · Nesting keeps related values in one place, so a single lookup suffices.
  7. Duplication buys read speed but charges work and risk on every update · The trade is fixed: fast simple reads now, update toil and disagreement risk later.
  8. One document per post with nested comments, for fast single-thing reads · The workload reads one nested thing at a time, which is the document sweet spot.
Worksheet · LightMySky