Schema-on-read
Summary: An approach where the structure of the data is implicit and only interpreted when the data is read, common in document databases.
Sources: raw/chapter2
Last updated: 2026-04-15
In contrast to the schema-on-write approach of relational databases (where the schema is explicit and enforced by the database), schema-on-read allows for arbitrary keys and values to be added to a document (source: chapter2, p. 39).
Key Characteristics
- Dynamic Type Checking: Similar to dynamic type checking in programming languages (source: chapter2, p. 40).
- Heterogeneous Data: Advantageous when items in a collection don’t all have the same structure, for example, if there are many different types of objects or the structure is determined by an external system (source: chapter2, p. 40).
- Schema Evolution: Changing the format of data doesn’t require a migration; the application code simply handles the case where old documents are read (source: chapter2, p. 40).