Transaction facts remember occurrences
Two real parcels each contain three copies.
The interview prompt
Two real parcels each contain three copies. The first event is delivered twice. A fourth message corrects the second parcel to two copies. Produce the dispatch count and net units, and say which producer guarantees you relied on.
Separate occurrence identity from correction identity
Write a four-message trace. D1 version 1 says three units. Its retry also says three. D2 version 1 says three. D2 version 2 says two, explicitly replacing version 1. Deduplicate identical versions before applying corrections. There are two dispatch occurrences and five units in the corrected view. A raw inbox can retain all four receipts for diagnosis.
For a current dispatch fact, key the business row by source and dispatch ID. Accept a later source version for the same occurrence. If you retain a change journal instead, project D2’s replacement as a delta of minus one when building totals. That delta is a correction to an earlier dispatch. Physical returns belong to their own process, with a link back when available.
Which version wins if D2 version 1 arrives after version 2? A monotonic producer version resolves it. Warehouse arrival time alone would mistake the older assertion for a newer one. For two different quantities under the same event ID and version, isolate the conflict. Picking whichever arrived last leaves a nonreproducible answer. A candidate earns credit for identifying which missing source property makes the desired result unknowable.
The model behind the answer
A transactional fact table gives each observed occurrence a row. In the dispatch feed, the first parcel carries four copies and the second carries two. Keep the event identifier, business timestamp, quantity, and the original order-line reference. Maya can now ask how many books left on Saturday or trace the two dispatches behind the completed order.
Two identical quantities can be legitimate. If the warehouse sends two parcels of three books each, deduplicating on order line, day, and quantity can silently discard half the books. Use an identifier that distinguishes the two dispatches and remains stable when either message is retried. Establish what the producer guarantees before choosing it.
Test it. Load the two genuine parcels and replay one message. The table should still contain two dispatches totaling six copies. Kimball on transaction facts
Give the ingestion agent an identity contract
Hand the agent the producer’s rules for occurrence ID, revision number and retry. Ask for a loader and a short change log showing which input changed each fact. Keep one input sequence for review: replay D2 version 1 after D2 version 2.
Reviewer decision. The late replay must leave two dispatches and five corrected units. Now offer a second payload with the same ID and version but a different quantity. The reviewer should see the conflict sent for investigation. A timestamp tie-breaker would silently choose a fact the producer never confirmed.
Further reading. The Data Warehouse Toolkit, 3rd ed., on transaction rows as measurement events.
One more question
A payment processor emits an authorization, a capture, and a void. Can you count payment messages to report settled sales?
Check your reasoning
Choose the lifecycle event behind the metric and confirm its meaning with the processor. An authorization reserves capacity, a capture requests payment, and a settlement feed may be a later source of evidence. Define the financial event and its reversals separately from message count.
Previous · One order line in two parcels · Next · Periodic snapshots remember the quiet days · Complete series map