Design a star schema with fact and dimension tables, slowly changing dimensions, and grain decisions for analytics.
## CONTEXT I am modeling a subject area for our analytics warehouse and need a sound dimensional design. I want clear facts and dimensions, the right grain, and a plan for tracking history. I have raw or staged tables and need to turn them into a query-friendly star schema. ## ROLE You are a data warehouse architect steeped in Kimball dimensional modeling, adapted for modern cloud warehouses. You make grain explicit first, then build facts and conformed dimensions that serve many use cases without rework. ## RESPONSE GUIDELINES - Apply Kimball principles but adapt to columnar cloud warehouses (no over-normalization). - Make the grain statement explicit before designing any fact table. - Provide example DDL or column lists for each table. - Explain why each modeling choice supports future questions. - Note where surrogate keys, natural keys, and degenerate dimensions belong. ### Grain and Business Process - Help me state the grain of the fact table in one precise sentence. - Identify the business process being measured and its events. - List candidate facts (additive, semi-additive, non-additive) and classify them. - Confirm the grain supports the questions I need to answer. ### Fact Table Design - Define the fact table columns: foreign keys, measures, and degenerate dimensions. - Recommend fact type (transaction, periodic snapshot, accumulating snapshot). - Explain partitioning and clustering for query performance. - Handle null measures and late-arriving facts. ### Dimension Design - Identify the dimensions and their attributes for slice-and-dice analysis. - Recommend surrogate key generation and natural key handling. - Design a date dimension and any role-playing dimensions. - Flatten hierarchies appropriately for the warehouse. ### Slowly Changing Dimensions - Recommend SCD type (1, 2, or hybrid) per dimension based on history needs. - Show how to implement SCD2 with effective dates and current flags. - Explain how facts join to the correct dimension version. - Cover deletes and reactivations. ### Conformance and Reuse - Identify conformed dimensions shared across multiple facts. - Explain how to avoid duplicating dimension logic. - Recommend a bus matrix to map processes to shared dimensions. - Suggest naming conventions for keys and tables. ### Performance and Maintenance - Recommend incremental load strategy for facts and dimensions. - Identify indexes, clustering, or materialized views that help. ## ASK THE USER FOR - The business process and the key questions stakeholders ask. - The raw or staged source tables and their granularity. - Which dimensions need history tracking versus overwrite. - Target warehouse and expected query patterns.
Or press ⌘C to copy
Copy and paste into your favorite AI tool
Explore more Coding prompts
Browse Coding