# Flattening and Expanding Structures **Domain:** Data Transformation / Persistence **Doc Type:** Canonical Concept Node **Maturity:** Artifact-Derived **Related:** [[wiki/Data Serialization|Data Serialization]], [[wiki/Structure|Structure]], [[wiki/Filesystem as Source of Truth|Filesystem as Source of Truth]] --- ## Definition **Flattening converts nested or relational structure into a representation suitable for storage, transport, indexing, or simple key access; expanding reconstructs the intended structure from that representation.** The pair must preserve enough type, ordering, escaping, and path information to round-trip safely. ## Project Context Shazam and KeyDB included operations for flattening and expanding structures so applications could keep canonical information in portable files. The same distinction appears in publishing: manuscripts remain structured sources while feeds, pages, and indexes are flattened channel-specific views. ## Key Insight **Flattening is not information loss when the expansion contract preserves the distinctions the system needs.** ## See Also [[wiki/Normalized Output|Normalized Output]], [[wiki/Rebuildable Projection|Rebuildable Projection]], [[wiki/Derived Artifact|Derived Artifact]], [[wiki/Technical Terms|Technical Terms]]