Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 45/ 160
03. Data Warehousing & Data Modeling

Fact Tables (Transaction, Periodic Snapshot, Accumulating Snapshot)

Choose the right fact grain for events, periodic measures, and processes that accumulate over time.

IntermediateTransaction Facts · Snapshots · Grain3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Fact Tables in one concrete design

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.

Key takeaway: 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 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.

Key takeaway: 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.

How it works, step by step

Step 1 of 4
Transaction Facts

1. 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.

event, period-entity, or process milestones
Key numbers at this step
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

Transaction Facts
Best for: One or more rows per business event at a repeatable grain, typically summed across time and most dimensions.

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.

Snapshots
Best for: One row per entity and time period representing a state that may only be summed across non-time dimensions.

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.

Grain
Best for: One row for a process instance whose milestone dates and durations are updated as the process advances.

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_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.

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?
Interview tip: Lead with the data path and failure boundary: 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. Then make the answer operational: 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.

Knowledge check

Loading quiz

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.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Dimensional Modeling Fundamentals (Kimball Methodology)
Next topic
Dimension Tables & Conformed Dimensions