Chapter 1
Data Models and Storage Basics
Represent product facts in a form a storage system can preserve and retrieve.
A data model describes the facts an application stores and the relationships or rules among them. Storage is the mechanism that preserves encoded data beyond one process or request. The model exists to turn a changing real-world domain into explicit records the software can validate, search, and update. Durable storage exists because process memory disappears during restarts and is not a safe owner for important facts.
Modeling starts by naming entities, their attributes, and stable identities. Next, define which attributes are required, which values are valid, and how records relate. The storage system encodes those records on durable media and maintains structures that locate them later. Reads reconstruct useful values; writes create, replace, or delete them according to the model's rules.
For a library, Book, Member, and Loan are separate concepts. A loan links one book to one member and records checkout and due dates. In practice, model product facts rather than screen layouts, distinguish durable source-of-truth data from rebuildable cache data, and plan how the model can evolve when a new requirement appears.
A useful data model makes product facts, identities, relationships, and rules explicit before selecting storage technology.
How to apply this
- Write down entities and invariants before designing records.
- Classify each value as durable source data, derived data, or disposable cache data.
- Choose stable identifiers that do not depend on mutable display names.
Situation
A team stores one large document matching today's UI, then struggles when two screens need different pieces of it.
Decision
Return to domain facts and their lifetimes, separating account identity, preferences, and derived presentation data.