Fact Tables (Transaction, Periodic Snapshot, Accumulating Snapshot)
Choose the right fact grain for events, periodic measures, and processes that accumulate over time.
In plain words
Event, period-entity, or process milestones. Next, dimensions plus durable source identity. Finally, dedupe events and verify interval coverage.
Think of it like…
Transaction facts are receipt lines, periodic snapshots are end-of-day inventory photographs, and accumulating snapshots are a parcel tracking form filled at each checkpoint.
Where you’ve seen it
Invoice line facts are transaction facts; fact_account_daily has one balance per account-day and is non-additive across time; a fact_order_fulfillment row is updated when ordered, packed, shipped, and delivered.
Words you’ll hear
- Transaction Facts
- One or more rows per business event at a repeatable grain, typically summed across time and most dimensions.
- Snapshots
- One row per entity and time period representing a state that may only be summed across non-time dimensions.
- Grain
- One row for a process instance whose milestone dates and durations are updated as the process advances.
- Operational boundary
- Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends. Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication.
Visual diagram
Theory & deep dive
Transaction Facts: the working mechanism
A fact table stores numeric measures and dimension keys at one grain: transaction facts represent events, periodic snapshots freeze a state per interval, and accumulating snapshots advance a process through milestones.
Event, period-entity, or process milestones. Dimensions plus durable source identity, then additive, semi-additive, or ratio; this exposes the state governed by Grain.
Invoice line facts are transaction facts; fact_account_daily has one balance per account-day and is non-additive across time; a fact_order_fulfillment row is updated when ordered, packed, shipped, and delivered.
Fact Tables: failure mode and production response
Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication. Track Fact uniqueness as "business grain key has no duplicates", and make Snapshot completeness visible to the dataset owner.
How it works, step by step
Step 1 of 41. Declare grain
Event, period-entity, or process milestones. A fact table stores numeric measures and dimension keys at one grain: transaction facts represent events, periodic snapshots freeze a state per interval, and accumulating snapshots advance a process through milestones.
- Fact uniqueness
- business grain key has no duplicates
- Snapshots
- One row per entity and time period representing a state that may only be summed across non-time dimensions.
When to use it & trade-offs
What it is
A fact table stores numeric measures and dimension keys at one grain: transaction facts represent events, periodic snapshots freeze a state per interval, and accumulating snapshots advance a process through milestones. Invoice line facts are transaction facts; fact_account_daily has one balance per account-day and is non-additive across time; a fact_order_fulfillment row is updated when ordered, packed, shipped, and delivered.
Why it matters: Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends. Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication.
When to reach for it
- Choose the right fact grain for events, periodic measures, and processes that accumulate over time.
- Choose Transaction Facts because it provides this capability: One or more rows per business event at a repeatable grain, typically summed across time and most dimensions.
- Keep evidence for Fact uniqueness at "business grain key has no duplicates" so the last production stage-Test history - dedupe events and verify interval coverage-remains testable.
When to avoid or be careful
- Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
- Do not conflate Snapshots with Transaction Facts. The second concept contributes different behavior: One row per entity and time period representing a state that may only be summed across non-time dimensions.
- Release only after this guardrail is in place: Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication.
Transaction Facts / Snapshots / Grain - roles, limits, and operating cost
Strengths: One or more rows per business event at a repeatable grain, typically summed across time and most dimensions. A fact table stores numeric measures and dimension keys at one grain: transaction facts represent events, periodic snapshots freeze a state per interval, and accumulating snapshots advance a process through milestones.
Watch out: Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
Strengths: One row per entity and time period representing a state that may only be summed across non-time dimensions. In this workflow it supports: Classify measures - additive, semi-additive, or ratio.
Watch out: The operating cost is real: expected entity-period combinations present.
Strengths: One row for a process instance whose milestone dates and durations are updated as the process advances. Its output can be checked with Semi-additivity.
Watch out: Operating guardrail: Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Transaction Facts, and how would Fact uniqueness reveal it?”
- “Why is Snapshots distinct from this behavior: one row for a process instance whose milestone dates and durations are updated as the process advances?”
- Production clue: Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
- Design probe: Write the grain before DDL, classify measures as additive/semi-additive/non-additive, choose a milestone or period key explicitly, and retain source event IDs plus load windows for deduplication.
Benchmarks & rules of thumb
- Fact uniqueness
- business grain key has no duplicates
- Snapshot completeness
- expected entity-period combinations present
- Semi-additivity
- the measure is never summed over time without a rule
Common mistakes & follow-ups
Common interview mistakes
- Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
- Reporting success from a job exit code without checking Fact uniqueness and Snapshot completeness.
- Treating this example as complete without replay, rollback, or access boundaries: Invoice line facts are transaction facts;
fact_account_dailyhas one balance per account-day and is non-additive across time; afact_order_fulfillmentrow is updated when ordered, packed, shipped, and delivered.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: One or more rows per business event at a repeatable grain, typically summed across time and most dimensions.
- What does the recovery plan do when this occurs? Mixing balances and event counts in a transaction fact encourages double-counting; a snapshot with multiple rows per interval or an accumulating fact with an overwritable history can invalidate trends.
- When is Transaction Facts insufficient for Snapshot completeness, and what does adding Snapshots cost in Fact uniqueness?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Fact Tables (Transaction, Periodic Snapshot, Accumulating Snapshot) with data engineer interview Q&A and hands-on practice.