learning-it by example

Back to the video

Declare the Grain: The Mistake That Breaks Reports

A daily sales report said 108 pounds when the shop sold 54, and one rule fixed it.

Video #257 ยท Data modelling

Steps in the video

  1. 0:00 A report said 108. The shop sold 54.
  2. 0:30 The idea
  3. 1:06 Setup
  4. 1:27 Two levels in the source
  5. 1:52 Mistake one: two grains in one table
  6. 2:17 Mistake two: a header fact on every line
  7. 2:41 The fix: one grain per table
  8. 3:09 Checking against the source
  9. 3:24 Run the mistakes
  10. 4:30 What this does not show
  11. 5:05 Mistakes to avoid
  12. 5:31 My take and next steps
  13. 5:59 Recap

Files

  • fixed.py (24 lines)
  • mixed.py (30 lines)
  • run.py (54 lines)
  • source.py (17 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

Four made-up orders in SQLite; it shows two grain mistakes and one fix, not allocation or dimension tables.

Sources

Learning IT by Example.