---
title: "Key-Value and Document Stores"
description: "Some workloads want a single key lookup and nothing else, and pay for the freedom by giving up joins and schema checks. A document store keeps whole nested objects together, which suits reading one th"
canonical: https://lightmysky.com/learn/computing/key-value-and-document-stores-mt_PfBDSgfeQX
source: https://lightmysky.com/learn/computing/key-value-and-document-stores-mt_PfBDSgfeQX.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Key-Value and Document Stores

Some workloads want a single key lookup and nothing else, and pay for the freedom by giving up joins and schema checks. A document store keeps whole nested objects together, which suits reading one thing at a time and makes any cross-cutting question harder.

Subject: Computing · Area: Data & Databases · Ages 20 to 21
Page: https://lightmysky.com/learn/computing/key-value-and-document-stores-mt_PfBDSgfeQX

## Ready when they can

- Model a small domain as documents and as normalised tables, and compare the queries
- Say what duplication buys in a document design and what it costs on update
- Name a workload that suits a key-value store and one that does not

## Lesson: One key in, whole thing back

Some workloads want a single key lookup and nothing else. You hand the database one key and it hands you back the whole value. It does not check the shape of your data, and it does not join things together for you. That freedom suits reading one thing at a time, and fails any question that cuts across many records.

**Example.** Think of var cat = { name: "Whiskers", age: 5, color: "gray" }. Each property has a key like name and a value like Whiskers, and cat.name reaches it, the way a key reaches its value. A cat can even hold an owner object with its own keys, and nesting values inside one object is exactly how a document store works: the whole nested thing sits together, so one lookup returns everything.

Document designs often repeat the same fact in many places. Storing the owner city inside every cat record makes reads fast, since one lookup returns everything. But if the owner moves, every copy must be updated, and a missed copy leaves the data disagreeing with itself. Duplication buys speed and simplicity on reads, and charges work and risk on every update.

**Tip.** To model a blog, keep each post with its comments as one document when readers open one post at a time. Ask which questions each design answers badly: documents struggle with cross-cutting questions like the average age of all cats in every city, since there is no join and no schema to lean on. Pick documents for single-thing reads, tables for cross-cutting questions.

**Recap.** Key lookups return whole values fast, documents keep nested things together, and duplication trades update pain for read speed.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Hash Tables and Near-Constant Lookup](https://lightmysky.com/learn/computing/hash-tables-and-near-constant-lookup-mt_7v94MJEdmJ)
- [Crash Recovery and Write-Ahead Logging](https://lightmysky.com/learn/computing/crash-recovery-and-write-ahead-logging-mt_JFPafSWOWF)
- [The Relational Model and Relational Algebra](https://lightmysky.com/learn/computing/the-relational-model-and-relational-algebra-mt_unDBd_Ug8T)

## Opens up

- [Wide-Column and Graph Stores](https://lightmysky.com/learn/computing/wide-column-and-graph-stores-mt_4a4yDq83fy)
