Choosing Your Strategy
The choice is made per column, and one dimension usually mixes rules. On dim_host, payout_email can be Type 1, tier Type 2 and region Type 3, all in the same table. A dimension is called Type 2 when at least one of its columns creates new rows.
| Property | Type 1 | Type 2 | Type 3 |
|---|---|---|---|
| On a change | Replace the value | Close the row, add a row | Shift the value into a previous column |
| One row means | The entity as known today | One version, valid for a window | The entity today plus one earlier value |
| Rows per entity | 1 | 1 per version | 1 |
| History kept | None | Every version, with dates | The latest change only |
| Past facts show | Today's value | The value at event time | Either label, across all facts |
| Breaks when | A closed period must stay fixed | The attribute changes daily | A second change arrives |
3 questions for each column
Ask them in this order
- Does any report group, filter or price facts by this column? If none does, choose Type 1 and stop.
- After the value changes, must reports on closed periods keep their published numbers? If yes, the column needs Type 2.
- Is the change a rare, planned relabeling, with people wanting all facts under both old and new labels? That is the Type 3 case.
- If reports group by the column but only ever want today's labels (as-is), Type 1 still fits. If that need may change, see When you are unsure below.
The second question separates as-was reporting from as-is reporting. As-was shows each fact with the attribute value from its own date, and finance, billing and compensation nearly always require it. As-is shows all facts under today's values, which suits questions about the entities themselves, such as how today's Superhosts grew over time.
Mixing rules on one table
Mixing has one mechanical consequence. When a Type 1 column changes on a table that also has Type 2 columns, the update must reach every version of that entity. If Marta's host_name is corrected, rows 101 and 104 both receive the fix and no new version is created. A name that differed between versions would split her bookings in any report grouped by name.
When you are unsure
The 2 main rules differ in what can be undone later. A Type 2 dimension can always serve as-is questions through its current rows. A Type 1 dimension can never serve as-was questions, because the old values were discarded and no backfill can invent them. For a column that reports group by, with an uncertain future, Type 2 is the reversible choice. Its extra rows cost storage, and a missing history cannot be bought back at any price.
One case argues against Type 2: an attribute that changes very often. A host's average review score moves after every review. Tracking it as Type 2 would add a dimension row per review, and the dimension would grow like a fact table. A value that changes with events is a measurement, and it belongs in a fact table, such as a periodic snapshot of each host's score.
Write the chosen rule beside each column in the table's documentation. The next person to build a report will read it to learn whether a number can change after it has been published.
About this lesson
This section is part of the Change Tracking lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.