Data Modelling · Lesson 5 of 6 · 16 min

Keeping history: slowly changing dimensions

Customers move and change plans. Keep every version, so old reports stay true.

The customers table only knows where each customer lives today. If Aino moved from Espoo to Tampere in March, a report on last year's revenue by city will wrongly credit Tampere. To answer questions about the past correctly, you keep every version of a row: a slowly changing dimension, type 2 (SCD2).

The shop's change log, customer_history, has one row per version of a customer, starting on valid_from. It covers 45 customers who moved city or changed segment.

← Previous: The star schema