Upload
owen-ross
View
40
Download
0
Embed Size (px)
DESCRIPTION
DSS Schemas. The Consolidated Star. The Normalized Star (Snowflake). DSS Schemas -- Agenda. Geography. Time. Year. Division. Region. Month. Dept. Market. Day. Class. Store. Item. Example Logical Model. Product. Fact Sales. Lookup Product - PowerPoint PPT Presentation
Citation preview
E D U C A T I O N
DSS SchemasDSS Schemas
E D U C A T I O N
DSS Schemas -- AgendaDSS Schemas -- Agenda
• The Consolidated Star
• The Normalized Star (Snowflake)
E D U C A T I O N
Fact Sales
Product Time
Day
Month
Year
Geography
Store
Market
Region
Example Logical ModelExample Logical Model
Item
Class
Dept
Division
E D U C A T I O N
Lookup Product
Product_keyProduct_descItem_idClass_idDept_idDivision_idLevel
Lookup Geography
Geo_keyGeo_descStore_idMarket_idRegion_idLevel
Fact Sales
Product_keyGeo_keyTime_keySales_DollarsSales_Units
Lookup Time
Time_keyTime_descDateMonth_idYear_idLevel
Consolidated Star Schema (1)Consolidated Star Schema (1)
E D U C A T I O N
Star #1
GEO_KEY GEO_DESC STORE_ID MARKET_ID REGION_ID LEVEL
1001 Boston 101 20 1 1
1002 Greenwich 102 20 1 1
1003 Providence 103 20 1 1
1004 Baltimore 104 10 1 1
1005 Philadelphia 105 10 1 1
1006 Charlotte 106 30 2 1
1007 Durham 107 30 2 1
1008 Greenville 108 30 2 1
1009 Atlanta 109 40 2 1
1010 Fayetteville 110 40 2 1
1011 Mid-Atlantic 10 1 2
1012 New England 20 1 2
1013 Carolinas 30 2 2
1014 Deep South 40 2 2
1015 Northeast 1 3
1016 South 2 3
Consolidated Star Schema LookupsConsolidated Star Schema Lookups
Lookup Geography
Geo_keyGeo_descStore_idMarket_idRegion_idLevel
Generic dimension key Null fields Level flag
E D U C A T I O N
• How do we get the following desired report?
Limitation of Consolidated Star (1)Limitation of Consolidated Star (1)
Sales $
1,000 1,000 1,000 2,0002,0002,000
Region
NortheastNortheast Northeast SouthSouth South
Store
BostonPhillyBaltimoreCharlotteAtlantaDurham
SELECT a1.Geo_desc Region, a2.Geo_desc StoreFROM LU_Geo a1, LU_Geo a2, Fact a3WHEREa1.Geo_Key = a2.Geo_Key
a2.Geo_Key = a3.Geo_Keya1.level = 3a2.level = 1
GROUP BY Region, Store
Lookup Geography
Geo_keyGeo_descStore_idMarket_idRegion_idLevel
Fact Sales
Product_keyGeo_keyTime_keySales_DollarsSales_Units
Necessary Tables:
• Self-join is necessary.
• Self-joins are generally undesirable.
E D U C A T I O N
Lookup Product
Product_keyItem_descClass_descDept_descDivision_descLevel
Lookup Geography
Geo_keyStore_descMarket_descRegion_descLevel
Fact Sales
Product_keyGeo_keyTime_keySales_DollarsSales_Units
Lookup Time
Time_keyDateMonth_descYear_idLevel
Consolidated Star Schema (2)Consolidated Star Schema (2)
E D U C A T I O N
Lookup Product
Product_keyItem_idItem_descClass_idClass_descDept_idDept_descDivision_idDivision_descLevel
Lookup Geography
Geo_keyStore_idStore_descMarket_idMarket_descRegion_idRegion_descLevel
Fact Sales
Product_keyGeo_keyTime_keySales_DollarsSales_Units
Lookup Time
Time_keyDateMonth_idMonth_descYear_idLevel
Consolidated Star Schema (3)Consolidated Star Schema (3)
E D U C A T I O N
Cons. Star #1 Cons. Star #2 Cons. Star #3
Consolidated Star Lookup ComparisonConsolidated Star Lookup Comparison
Lookup Geography
Geo_keyStore_idStore_descMarket_idMarket_descRegion_idRegion_descLevel
Lookup Geography
Geo_keyStore_descMarket_descRegion_descLevel
Lookup Geography
Geo_keyGeo_descStore_idMarket_idRegion_idLevel
E D U C A T I O N
Time_key
DateDateDateDate DateDateDateDateDateDateDateDate Month...
Fact Sales
Product_keyGeo_keyTime_keySales_Dollars
Consolidated Star Schema Fact TablesConsolidated Star Schema Fact Tables
Product_key
ItemClassDeptDivisionItemClassDeptDivision ItemClassDeptDivision Item...
Geo_key
Store Store StoreStoreMarketMarketMarketMarketRegionRegion Region Region Store...
Contains all possible levels of
data.
Sales
1002003005002003505006005004507509001500...
E D U C A T I O N
Lookup Product
Product_keyProduct_descItem_idClass_idDept_idDivision_idLevel
Lookup Geography
Geo_keyGeo_descStore_idMarket_idRegion_idLevel
Fact Sales
Product_keyGeo_keyTime_keySales_DollarsSales_Units
Lookup Time
Time_keyTime_descDateMonth_idYear_idLevel
Consolidated Star Schema SummaryConsolidated Star Schema Summary
Select Product_desc, Geo_desc, Time_desc, Sales_Dollars, Sales_UnitsFrom Fact_Sales F,
Lookup_Product P, Lookup_Geography G, Lookup_Time T
Where F.Product_key = P.Product_keyAnd F.Geo_key = G.Geo_keyAnd F.Time_key = T.Time_keyAnd G.Level = ??And P.Level = ??And T.Level = ??
E D U C A T I O N
Normalized Star Schema (1)Normalized Star Schema (1)
Fact Sales
Item_idStore_idDateSales_DollarsSales_Units
Lookup Division
Division_idDivision_desc
Lookup Dept
Dept_idDept_descDivision_id
Lookup Class
Class_idClass_descDept_id
Lookup Item
Item_idItem_descClass_id
Lookup Store
Store_idStore_descMarket_id
Lookup Market
Market_idMarket_descRegion_id
Lookup Region
Region_idRegion_desc
Lookup Day
DateMonth_id
Lookup Month
Month_idMonth_descYear_id
Lookup Year
Year_id
E D U C A T I O N
Normalized Star #1
REGION_ID REGION_DESC
1 Northeast
2 South
MARKET_ID MARKET_DESC REGION_ID
10 Mid-Atlantic 1
20 New England 1
30 Carolinas 2
40 Deep South 2
STORE_ID STORE_DESC MARKET_ID
101 Boston 20
102 Greenwich 20
103 Providence 20
104 Baltimore 10
105 Philadelphia 10
106 Charlotte 30
107 Durham 30
108 Greenville 30
109 Atlanta 40
110 Fayetteville 40
Lookup Store
Store_idStore_descMarket_id
Lookup Market
Market_idMarket_descRegion_id
Lookup Region
Region_idRegion_desc
Normalized Star Schema LookupsNormalized Star Schema Lookups
E D U C A T I O N
Normalized Star Schema (2)Normalized Star Schema (2)
Fact Sales
Item_idStore_idDateSales_DollarsSales_Units
Lookup Division
Division_idDivision_desc
Lookup Dept
Dept_idDept_descDivision_id
Lookup Class
Class_idClass_descDept_idDivision_id
Lookup Item
Item_idItem_descClass_idDept_idDivision_id
Lookup Store
Store_idStore_descMarket_idRegion_id
Lookup Market
Market_idMarket_descRegion_id
Lookup Region
Region_idRegion_desc
Lookup Day
DateMonth_idYear_id
Lookup Month
Month_idMonth_descYear_id
Lookup Year
Year_id
E D U C A T I O N
Normalized Star #2
REGION_ID REGION_DESC
1 Northeast
2 South
MARKET_ID MARKET_DESC REGION_ID
10 Mid-Atlantic 1
20 New England 1
30 Carolinas 2
40 Deep South 2
Lookup Store
Store_idStore_descMarket_idRegion_id
Lookup Market
Market_idMarket_descRegion_id
Lookup Region
Region_idRegion_desc
Normalized Star Schema Lookups (2)Normalized Star Schema Lookups (2)
STORE_ID STORE_DESC MARKET_ID REGION_ID
101 Boston 20 1
102 Greenwich 20 1
103 Providence 20 1
104 Baltimore 10 1
105 Philadelphia 10 1
106 Charlotte 30 2
107 Durham 30 2
108 Greenville 30 2
109 Atlanta 40 2
110 Fayetteville 40 2
Denormalized attribute id
column
E D U C A T I O N
Normalized Star Schema (3)Normalized Star Schema (3)
Fact Sales
Item_idStore_idDateSales_DollarsSales_Units
Lookup Division
Division_idDivision_desc
Lookup Dept
Dept_idDept_descDivision_idDivision_desc
Lookup Class
Class_idClass_descDept_idDept_descDivision_idDivision_desc
Lookup Item
Item_idItem_descClass_idClass_descDept_idDept_descDivision_idDivision_desc
Lookup Store
Store_idStore_descMarket_idMarket_descRegion_idRegion_desc
Lookup Market
Market_idMarket_descRegion_idRegion_desc
Lookup Region
Region_idRegion_desc
Lookup Day
DateMonth_idMonth_descYear_id
Lookup Month
Month_idMonth_descYear_id
Lookup Year
Year_id
E D U C A T I O N
Snowflake #1 Snowflake #2 Snowflake #3
Lookup Store
Store_idStore_descMarket_idMarket_descRegion_idRegion_desc
Lookup Store
Store_idStore_descMarket_idRegion_id
Lookup Store
Store_idStore_descMarket_id
Normalized Star Lookups ComparisonNormalized Star Lookups Comparison
E D U C A T I O N
Atomic level data Aggregate level data
Fact Sales - Stores
Item_idStore_idDateSales_DollarsSales_Units
Normalized Star Schema Fact TablesNormalized Star Schema Fact Tables
Fact Sales - Markets
Item_idMarket_idDateSales_DollarsSales_Units
Fact Sales - Regions
Item_idRegion_idDateSales_DollarsSales_Units
E D U C A T I O N
Why ‘Higher Level’ Attribute Lookup Tables?Why ‘Higher Level’ Attribute Lookup Tables?
• Below is pictured a Snowflake Schema without any higher-level lookup tables. Note its similarity to the Consolidated Star Schema.
• Consider the questions below.
Fact Sales - Stores
Item_idStore_idDateSales_DollarsSales_Units
Fact Sales - Regions
Item_idRegion_idDateSales_DollarsSales_Units
Lookup Item
Item_idItem_descClass_idClass_descDept_idDept_descDivision_idDivision_desc
Lookup Store
Store_idStore_descMarket_idMarket_descRegion_idRegion_desc
Lookup Day
DateMonth_idMonth_descYear_id
E D U C A T I O N
• Higher level lookup tables provide for more efficient browsing.
• Higher level lookup tables are what enable the use of aggregate fact tables.
Fact Sales - Stores
Item_idStore_idDateSales_DollarsSales_Units
Fact Sales - Regions
Item_idRegion_idDateSales_DollarsSales_Units
Lookup Division
Division_idDivision_desc
Lookup Dept
Dept_idDept_descDivision_idDivision_desc
Lookup Item
Item_idItem_descClass_idClass_descDept_idDept_descDivision_idDivision_desc
Lookup Store
Store_idStore_descMarket_idMarket_descRegion_idRegion_desc
Lookup Region
Region_idRegion_desc
Lookup Day
DateMonth_idMonth_descYear_id
Why ‘Higher Level’ Attribute Lookup TablesWhy ‘Higher Level’ Attribute Lookup Tables
E D U C A T I O N
Fact Sales - Stores
Item_idStore_idDateSales_DollarsSales_Units
Normalized Star Schema SummaryNormalized Star Schema Summary
Fact Sales - Regions
Item_idRegion_idDateSales_DollarsSales_Units
Lookup Division
Division_idDivision_desc
Lookup Dept
Dept_idDept_descDivision_idDivision_desc
Lookup Item
Item_idItem_descClass_idClass_descDept_idDept_descDivision_idDivision_desc
Lookup Store
Store_idStore_descMarket_idMarket_descRegion_idRegion_desc
Lookup Region
Region_idRegion_desc
Lookup Day
DateMonth_idMonth_descYear_id
E D U C A T I O N
• Consolidated Star
• Few Tables / Few Joins
• Easy SQL
• No support for M:M relationships
• Limited support for characteristic attributes
• Inflexible schema
• Not scalable
The Consolidated Star vs.The SnowflakeThe Consolidated Star vs.The Snowflake
• Snowflake
• More Tables / More Joins
• More complex SQL
• M:M is possible
• Characteristic attributes fully supported
• Flexible schema
• Scalable
vs.
E D U C A T I O N
Continue Case StudyContinue Case Study
• Continue working on the Case Study.