Dimensional Modeling

7,348 views
7,376 views

Published on

Published in: Technology, Business, Travel
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,348
On SlideShare
0
From Embeds
0
Number of Embeds
3,448
Actions
Shares
0
Downloads
283
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Dimensional Modeling

  1. 1. Dimensional Modeling for SQL Server Analysis Services James Snape Application Development Consulting Microsoft Limited
  2. 2. The Kimball Process
  3. 3. Session Objectives Why do we need a dimensional model? What is a dimensional model? How do you design a dimensional model?
  4. 4. Dimensional Models are for Users
  5. 5. The Wrong Model OLTP != OLAP ProductSubcategory (Production) ProductCategory (Production) ProductModel (Production) Product (Production) ProductInventory (Production) PurchaseOrderDetail (Purchasing) SalesPerson (Sales) PurchaseOrderHeader (Purchasing) Employee (HumanResources) Store (Sales) Person (Person) Vendor (Purchasing) SalesReason (Sales) SalesOrderHeader (Sales) Customer (Sales) SalesOrderHeaderSalesReason (Sales SalesTerritory (Sales) SalesOrderDetail (Sales)
  6. 6. Dimensional Model/Star Schema Single central fact Multiple denormalized dimensions DimPromotion DimProduct DimEmployee FactResellerSales DimReseller DimTime
  7. 7. The Four Steps Choose the Business Process Declare the Grain Identify the Dimensions Identify the Facts
  8. 8. Choose the Business Process
  9. 9. Follow the Value Chain Manufacture Inventory Order Delivery Sale Common dimensions Product Item Date
  10. 10. Enterprise Bus Architecture Sales Inventory Orders Delivery Finance      Time   Employee    Customer   Product   Location  Promotion    Store
  11. 11. Declare the Grain
  12. 12. Fundamental Grains Transaction (or line item) Periodic snapshot e.g. Bank balance Accumulating snapshot e.g. Order state
  13. 13. Identify the Dimensions
  14. 14. High Level Dimensional Model Promotion Sales Reason Order Date Start Date Reason Type Discount Percent Year Reason Category Month Day Is Weekend Internet Sales Territory Ship Date Country State Sales Is Weekend Day Month Year Is Weekend Product Name Day Colour Month Category Year Gender SKU City Product Delivery Date Full Name Customer ID Customer
  15. 15. Attribute Keys and Names All attributes have both a key and a name Keys must be unique Cust ID Full Name Marital City Country MJ0001 Mary Jones S London UK Attribute Key Name Customer ID Cust ID Cust ID Full Name Cust ID Full Name Marital Status Marital Marital City City City Country Country Country
  16. 16. Attribute Relations and Hierarchies Country Country State Marital City Gender Gender State Customer Customer Customer Age Gender Marital City Customer State Gender City Country Marital Customer Attributes Hierarchies
  17. 17. Slowly Changing Dimensions Change happens!
  18. 18. Type I: Overwrite the attribute Cust Key Cust ID Full Name Marital City Country 1 MJ0001 Mary Jones S London UK Cust Key Sales Amount 1 £400
  19. 19. Type I: Overwrite the attribute Cust Key Cust ID Full Name Marital City Country 1 MJ0001 Mary Smith M London UK Cust Key Sales Amount 1 £400
  20. 20. Type I: Overwrite the attribute Cust Key Cust ID Full Name Marital City Country 1 MJ0001 Mary Smith M London UK Cust Key Sales Amount 1 £400 1 £200 1 £150
  21. 21. Type II: Add a new dimension row Cust Key Cust ID Full Name Marital City Country Valid From Valid To 1 MJ0001 Mary Jones S London UK 14/12/2000 NULL Cust Key Sales Amount 1 £400
  22. 22. Type II: Add a new dimension row Cust Key Cust ID Full Name Marital City Country Valid From Valid To 1 MJ0001 Mary Jones S London UK 14/12/2000 01/02/2009 2 MJ0001 Mary Jones S Leeds UK 01/02/2009 NULL Cust Key Sales Amount 1 £400
  23. 23. Type II: Add a new dimension row Cust Key Cust ID Full Name Marital City Country Valid From Valid To 1 MJ0001 Mary Jones S London UK 14/12/2000 01/02/2009 2 MJ0001 Mary Jones S Leeds UK 01/02/2009 NULL Cust Key Sales Amount 1 £400 2 £200 2 £150
  24. 24. Type III: Add a new attribute Cust Key Cust ID Full Name Marital City Country 1 MJ0001 Mary Jones S London UK Cust Key Sales Amount 1 £400
  25. 25. Type III: Add a new attribute Cust Key Cust ID Full Name Marital City Country Previous Country 1 MJ0001 Mary Jones S London USA UK Cust Key Sales Amount 1 £400
  26. 26. Type III: Add a new attribute Cust Key Cust ID Full Name Marital City Country Previous Country 1 MJ0001 Mary Jones S London USA UK Cust Key Sales Amount 1 £400 1 £200 1 £150
  27. 27. Date and Time Create your own date dimension Attribute keys must be unique “January” vs. “January 2009” Time of day – do you really need it? Time zones – do you really need them? Pre-calculate durations into fact rows Use calculated surrogate dimension keys E.g. Key = 10000 x year + 100 x month + day
  28. 28. Role Playing Dimensions
  29. 29. Parent-Child Dimensions How do you model composite or hierarchical structures? E.g. Bill of Materials or Employee/Manager
  30. 30. Mini-Dimensions How do you manage high frequency, low cardinality change in a dimension? Country State Age Gender Marital Current Location City Employee Employee Location
  31. 31. Degenerate Dimensions How do you deal with the high cardinality dimensions like “transaction number”?
  32. 32. Junk Dimensions How do you deal with the low cardinality, non-related dimensions like gender or other booleans?
  33. 33. Identify the Facts Facts (Kimball) == Measures (Analysis Services)
  34. 34. What makes a good fact? Numeric Additive Yes you can have strings Yes you can have non-additive values e.g. Averages But they are not very useful
  35. 35. Fact-less Facts How to you record an event that has no measures? NB: Attended always = 1
  36. 36. Semi-additive Measures and Custom Rollups Semi-additive in Time Configurable by Account
  37. 37. Currency and Units of Measure How do you enable currency conversions? How do you represent amounts in different units? e.g. 400 bikes == 2 pallets == 10 shipping crates Put the conversion factors in the fact table Expose the calculated results in the cube OR Use a separate conversion measure group See Exchange Rates in AdventureWorks
  38. 38. The Four Steps Choose the Business Process Declare the Grain Identify the Dimensions Identify the Facts
  39. 39. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

×