Schema-on-Write vs Schema-on-Read
People think schema-on-read means data with no schema. Both have a schema. Schema-on-write checks each row against the shape when it is stored. Schema-on-read stores data as it comes and applies the shape in each query. The first catches bad data early. The second lets you load first and ask later.
Schema-on-Write
The shape is fixed first. Data that does not fit is turned away.
Schema-on-write means the shape of the data is set before any data goes in. Each table is created with fixed columns and types. When a row is written, the database checks it against that shape. A row that does not fit is turned away. Classic databases and warehouses work this way.
Schema-on-Read
Store data as it comes. The shape is set later, when it is read.
Schema-on-read means data is stored as it comes, with no shape forced on it. The shape is applied later, by the query that reads it. Each reader can pick the fields it needs and how to treat them. This makes loading fast and easy. The cost is that bad data is only found when someone reads it.
In one line
- Schema-on-Write
- The shape is fixed first. Data that does not fit is turned away.
- Schema-on-Read
- Store data as it comes. The shape is set later, when it is read.