🧭Schema-on-Write
Also known as Schema on Write
The shape is fixed first. Data that does not fit is turned away.
Think of it like
It is like a mailbox slot. Only letters of the right size fit through.
Example
A bank's payments table only takes amounts as numbers. A file with "ten pounds" in that column fails to load.
Why it matters
Bad data is caught at the door. Everyone who reads the table can trust its shape.
Definition
Example code
sql
CREATE TABLE visit (id INT, guests INT);
INSERT INTO visit VALUES (1, 'ten');
-- ERROR: invalid input syntax for type integer: "ten"Common mistake
Key takeaways
- 1Shape first. Columns and types come before data.
- 2Checked on write. Each row is tested as it goes in.
- 3Trusted reads. Readers know what to expect.