learning-it by example

Back to the video

Fact Table Types: Transaction, Snapshot, Accumulating

The same nine order events become three fact tables, and the shipped orders took 2 days on average.

Video #258 ยท Data modelling

Steps in the video

  1. 0:00 Nine events, three fact tables, three answers
  2. 0:30 The idea
  3. 1:08 Setup
  4. 1:26 The events
  5. 1:51 Three tables, three grains
  6. 2:19 Recording an event
  7. 2:52 The snapshot query and the build
  8. 3:21 Run each table
  9. 4:46 What this does not show
  10. 5:12 Mistakes to avoid
  11. 5:38 My take and next steps
  12. 5:59 Recap

Files

  • facts.py (50 lines)
  • run.py (44 lines)
  • source.py (15 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

Nine made-up events in SQLite; the snapshot is computed from the events, the averages skip open orders, and no dimension tables are shown.

Sources

Learning IT by Example.