Skip to content

Document Model and Hierarchical Data

When data naturally forms hierarchies and is typically accessed as a whole, embedding related data in nested structures eliminates joins and aligns storage with access patterns.

Tension Addressed

Normalization vs. Query Performance; Schema Rigidity vs. Flexibility

Recognizable As

Nested objects, embedded arrays, self-contained documents, schemaless or schema-optional storage, aggregate-oriented access patterns

Canonical Sources

Kleppmann, "Designing Data-Intensive Applications" (2017); Fowler, "Aggregate" pattern in Domain-Driven Design

Transfers To

API response design, configuration files, serialization formats, message payloads, any hierarchically structured data

The document model excels when data has clear ownership boundaries (aggregates) and relationships are primarily one-to-many within those boundaries. It struggles with many-to-many relationships that cross document boundaries.