Write down what one row claims
An export repeats customer names, order dates and product information on every order line. Its rows are (O1,line1,C1,North,2026-01-05,P1,2,10), (O1,line2,C1,North,2026-01-05,P2,1,30), and (O2,line1,C1,North,2026-01-06,P1,3,10). The final two values are quantity and the transaction’s unit price. The intended grain is one order line, identified by the pair (order_id,line_no). Repeated product P1 is not a duplicate line: it occurs on two different orders.
For this model, an order_id determines customer_id and order_date; customer_id determines the current customer name; and (order_id,line_no) determines product_id, quantity and transaction unit price. A functional dependency is a rule about all valid states in the intended domain, not merely an accidental pattern in these three rows. The fact that all observed orders belong to C1 does not mean that customer_id determines order_id. Use business semantics and identifiers to distinguish a rule from a coincidence.
Likewise, product_id does not necessarily determine transaction unit price. The same product can be sold at different dates, discounts or contract prices. Moving the observed line price into a single current product record would silently change the represented fact. Good normalization starts by identifying the meaning and time basis of the attributes, rather than by removing every repeated-looking value.
Explain the anomaly and the decomposition
If the customer’s current name changes, the export requires changing three copies. Updating only two creates inconsistent current names. Storing a customer before it has an order may be impossible in a table whose required key is an order line. Deleting its final line may accidentally delete the only recorded current name. These are update, insertion and deletion anomalies arising from storing facts of different grains in one relation.
Decompose into customers(customer_id PRIMARY KEY,name), orders(order_id PRIMARY KEY,customer_id REFERENCES customers,order_date), and lines(order_id REFERENCES orders,line_no,product_id,quantity,unit_price,PRIMARY KEY(order_id,line_no)). In this fixture, keep the transaction price on lines. Appropriate NOT NULL and domain checks make required attributes explicit. A product table may hold product descriptions and current catalog prices, but it does not replace the historical price agreed for an order line.
The reconstruction joins each line to exactly one order and each order to exactly one customer. Parent-key uniqueness prevents multiplication, and valid non-NULL references prevent dropped child facts for this inner-join reconstruction. Check those conditions rather than assuming a join is lossless because it executes. A name table that contains two rows for C1 can double every line; a missing order parent can remove a line. Constraints and exact-pair comparisons make the intended decomposition auditable.
Validate facts at the original grain
O1 totals 2×10+1×30=50, and O2 totals 3×10=30. The grand total is 80. A successful reconstruction must preserve not only that total but every keyed line, its customer, date, quantity and unit price. Two offsetting price changes can retain 80 while corrupting individual transactions. Compare both directions of an exact set difference, and separately check multiplicity when the original representation permits duplicates. An EXCEPT comparison uses set semantics and cannot by itself prove duplicate counts are preserved.
In the runnable fixture, both the original export and the reconstructed table have a unique composite line key, so equality of keyed rows establishes the relevant row-level preservation. In a less constrained staging table, first inspect duplicate key counts and conflicting attributes. Do not use DISTINCT to make inconsistent source rows disappear without a reconciliation policy. Correctness is a statement about the intended facts, not just the number of rows a query happens to return.
Current names and invoice-time names can legitimately differ. If issued documents must retain the name used at issuance, model an immutable document snapshot or a versioned relationship in addition to the current customer master. Updating a current master then changes current-name reports while leaving the issuance snapshot intact. This is a choice of facts and history, not a defect that can be solved by insisting on either universal duplication or universal removal of duplication.
Normalization also does not prove that an identifier was assigned correctly, an amount was measured accurately, or an application has appropriate permissions. Preserve source provenance, units, date conventions and update authority. Test schema constraints with invalid records in a disposable fixture, then assess any operational migration separately. The in-memory demonstration is an explanation of a small model; it is not evidence that a production conversion, concurrent import or retention policy has been validated.
Worked example: The exact reconstruction ledger
The original and normalized reconstructions contain the same three keyed lines. O1=50, O2=30 and total=80. Inserting another line with the existing key (O1,1) must fail. A duplicate product code on a different valid line is allowed. These tests distinguish the identity rule from an overly broad uniqueness rule on product_id.
Worked example: A price change that must not rewrite the past
Suppose P1 now has a catalog price of 12. Retaining transaction prices of 10 keeps O1=50 and O2=30. Recomputing historical lines with the new catalog price would produce O1=54 and O2=36, total=90. Both queries can be fast and syntactically valid; only the first preserves the stipulated transaction-price fact.