How to Track State with Type 2 Dimensional Models - Shopify
Aug 27, 2020

Summary
This post introduces and details the implementation of Type 2 dimensional models for tracking historical state in data, specifically for use cases like tracking user language preferences over time. It contrasts Type 1 (current state) and Type 2 (historical state) models, outlines three options for implementing Type 2 models (modifying core application design, stitching database snapshots, and adding database event logging), and provides a detailed PySpark implementation recipe for building Type 2 dimensions from event logs. The post also discusses the use of dbt for data modeling and the challenges and trade-offs associated with each implementation option.
More from the Data Store Selection and Usage trail
- We replaced Redis with MySQL for inventory reservations—and it scaled (2026) - Shopify
- Mitigating Deadlocks in high concurrency environments - Shopify
- Safely Adding NOT NULL Columns to Your Database Tables - Shopify
- Double Entry Transition Tables: How We Track State Changes At Shopify - Shopify
- Shopify’s Unique Data Science Hierarchy Of Needs - Shopify