Agent Wranglers

DAT-5Recommended

Keep one fact in one place

Store each fact once, and derive the rest. Copies of a fact drift apart sooner or later.

How to do it

Normalise to third normal form by default. Store a customer's address on the customer, not on every order, unless the order must keep the address as it was at the time. Copy data on purpose only for history or proven speed needs, and write down which copy is the source. The interface follows the same idea in Compute values instead of storing them. A price frozen on an order is a separate fact, as Freeze what the customer agreed to on the order explains.

How to check

A file in the repository lists every copied column with its source and how the copy is kept in step. A script finds non-key columns that share a name and type across tables. It fails on any that the file does not list.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/schema-design/normalise">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.