Вы находитесь на странице: 1из 23

DSS Schemas

EDUCATION

DSS Schemas -- Agenda

The Consolidated Star

The Normalized Star (Snowflake)

EDUCATION

Example Logical Model


Product Division Geography Region Time Year

Dept

Market

Month

Class

Store

Day

Item

Fact Sales
EDUCATION

Consolidated Star Schema (1)


Lookup Product Product_key Product_desc Item_id Class_id Dept_id Division_id Level Lookup Time Fact Sales Time_key Time_desc Date Month_id Year_id Level

Lookup Geography Geo_key Geo_desc Store_id Market_id Region_id Level

Product_key Geo_key Time_key Sales_Dollars Sales_Units

EDUCATION

Consolidated Star Schema Lookups


GEO_KEY GEO_DESC STORE_ID MARKET_ID REGION_ID LEVEL

1001 1002

Bost on Greenw ich Providence Balt imore Philadelphia Charlot t e Durham Greenville A t lant a Fayet t eville M id-A t lant ic New England Carolinas Deep Sout h Nort heast Sout h

101 102 103 104 105 106 107 108 109 110

20 20 20 10 10 30 30 30 40 40 10 20 30 40

1 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2

1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 3

Star #1
Lookup Geography Geo_key Geo_desc Store_id Market_id Region_id Level

1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016

Generic dimension key

Null fields

Level flag

EDUCATION

Limitation of Consolidated Star (1) How do we get the following desired report?
Region Store Sales $

Northeast Northeast Northeast South South South

Boston Philly Baltimore Charlotte Atlanta Durham

1,000 1,000 1,000 2,000 2,000 2,000

Necessary Tables:
Lookup Geography Geo_key Geo_desc Store_id Market_id Region_id Level Fact Sales Product_key Geo_key Time_key Sales_Dollars Sales_Units

SELECT a1.Geo_desc Region, a2.Geo_desc Store FROM LU_Geo a1, LU_Geo a2, Fact a3 WHERE a1.Geo_Key = a2.Geo_Key a2.Geo_Key = a3.Geo_Key a1.level = 3 a2.level = 1 GROUP BY Region, Store

Self-join is necessary.

Self-joins are generally undesirable.

EDUCATION

Consolidated Star Schema (2)


Lookup Product Product_key Item_desc Class_desc Dept_desc Division_desc Level Lookup Time Fact Sales

Lookup Geography Geo_key Store_desc Market_desc Region_desc Level

Product_key Geo_key Time_key Sales_Dollars Sales_Units

Time_key Date Month_desc Year_id Level

EDUCATION

Consolidated Star Schema (3)


Lookup Product Product_key Item_id Item_desc Class_id Class_desc Dept_id Dept_desc Division_id Division_desc Level

Lookup Time Fact Sales

Lookup Geography Geo_key Store_id Store_desc Market_id Market_desc Region_id Region_desc Level

Product_key Geo_key Time_key Sales_Dollars Sales_Units

Time_key Date Month_id Month_desc Year_id Level

EDUCATION

Consolidated Star Lookup Comparison

Cons. Star #1

Cons. Star #2

Cons. Star #3

Lookup Geography Geo_key Geo_desc Store_id Market_id Region_id Level

Lookup Geography Geo_key Store_desc Market_desc Region_desc Level

Lookup Geography Geo_key Store_id Store_desc Market_id Market_desc Region_id Region_desc Level

EDUCATION

Consolidated Star Schema Fact Tables

Product_key Item Class Dept Division Item Class Dept Division Item Class Dept Division Item ...

Geo_key Store Store Store Store Market Market Market Market Region Region Region Region Store ...

Time_key Date Date Date Date Date Date Date Date Date Date Date Date Month ...

Sales 100 200 300 500 200 350 500 600 500 450 750 900 1500 ...

Fact Sales Product_key Geo_key Time_key Sales_Dollars

Contains all possible levels of data.

EDUCATION

Consolidated Star Schema Summary


Lookup Product Product_key Product_desc Item_id Class_id Dept_id Division_id Level Lookup Time Fact Sales Product_key Geo_key Time_key Sales_Dollars Sales_Units Time_key Time_desc Date Month_id Year_id Level

Lookup Geography Geo_key Geo_desc Store_id Market_id Region_id Level

Select Product_desc, Geo_desc, Time_desc, Sales_Dollars, Sales_Units From Fact_Sales F, Lookup_Product P, Lookup_Geography G, Lookup_Time T Where F.Product_key = P.Product_key And F.Geo_key = G.Geo_key And F.Time_key = T.Time_key And G.Level = ?? And P.Level = ?? And T.Level = ??

EDUCATION

Normalized Star Schema (1)


Lookup Division Division_id Division_desc Lookup Region Region_id Region_desc Lookup Year Year_id

Lookup Month Lookup Dept Dept_id Dept_desc Division_id Lookup Market Market_id Market_desc Region_id Month_id Month_desc Year_id

Lookup Class Class_id Class_desc Dept_id Lookup Store Store_id Store_desc Market_id

Lookup Day Date Month_id

Lookup Item Item_id Item_desc Class_id

Fact Sales Item_id Store_id Date Sales_Dollars Sales_Units

EDUCATION

Normalized Star Schema Lookups


Normalized Star #1
Lookup Market Market_id Market_desc Region_id Lookup Region Region_id Region_desc
REGION_ID REGION_DESC

1 2

Northeast South

Lookup Store Store_id Store_desc Market_id

MARKET_ID

MARKET_DESC REGION_ID

10 20
STORE_ID STORE_DESC MARKET_ID

Mid-Atlantic New England Carolinas Deep South

1 1 2 2

101 102 103 104 105 106 107 108 109 110

Boston Greenwich Providence Baltimore Philadelphia Charlotte Durham Greenville Atlanta Fayetteville

20 20 20 10 10 30 30 30 40 40

30 40

EDUCATION

Normalized Star Schema (2)


Lookup Division Division_id Division_desc Lookup Region Region_id Region_desc Lookup Year Year_id

Lookup Dept Dept_id Dept_desc Division_id Lookup Market Market_id Market_desc Region_id

Lookup Month Month_id Month_desc Year_id

Lookup Class
Class_id Class_desc Dept_id Division_id Lookup Store Store_id Store_desc Market_id Region_id

Lookup Day Date Month_id Year_id

Lookup Item
Item_id Item_desc Class_id Dept_id Division_id

Fact Sales Item_id Store_id Date Sales_Dollars Sales_Units

EDUCATION

Normalized Star Schema Lookups (2)


Normalized Star #2
Lookup Market Market_id Market_desc Region_id Lookup Region Region_id Region_desc
REGION_ID REGION_DESC

1 2

Northeast South

Lookup Store Store_id Store_desc Market_id Region_id

MARKET_ID

MARKET_DESC REGION_ID

10 20
STORE_DESC MARKET_ID REGION_ID

Mid-Atlantic New England Carolinas Deep South

1 1 2 2

STORE_ID

30 40

101 102 103 104 105 106 107 108 109 110

Boston Greenwich Providence Baltimore Philadelphia Charlotte Durham Greenville Atlanta Fayetteville

20 20 20 10 10 30 30 30 40 40

1 1 1 1 1 2 2 2 2 2

Denormalized attribute id column

EDUCATION

Normalized Star Schema (3)


Lookup Division Division_id Division_desc Lookup Dept Dept_id Dept_desc Division_id Division_desc Lookup Class Class_id Class_desc Dept_id Dept_desc Division_id Division_desc Lookup Month Lookup Market Market_id Market_desc Region_id Region_desc Month_id Month_desc Year_id Lookup Region Region_id Region_desc Lookup Year Year_id

Lookup Day Lookup Store Store_id Store_desc Market_id Market_desc Region_id Region_desc Date Month_id Month_desc Year_id

Lookup Item
Item_id Item_desc Class_id Class_desc Dept_id Dept_desc Division_id Division_desc

Fact Sales Item_id Store_id Date Sales_Dollars Sales_Units

EDUCATION

Normalized Star Lookups Comparison

Snowflake #1

Snowflake #2

Snowflake #3

Lookup Store

Lookup Store

Lookup Store

Store_id Store_desc Market_id

Store_id Store_desc Market_id Region_id

Store_id Store_desc Market_id Market_desc Region_id Region_desc

EDUCATION

Normalized Star Schema Fact Tables

Atomic level data

Aggregate level data

Fact Sales - Stores Item_id Store_id Date Sales_Dollars Sales_Units

Fact Sales - Markets Item_id Market_id Date Sales_Dollars Sales_Units

Fact Sales - Regions Item_id Region_id Date Sales_Dollars Sales_Units

EDUCATION

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.
Fact Sales - Regions Item_id Region_id Date Sales_Dollars Sales_Units

Consider the questions below.

Lookup Store Store_id Store_desc Market_id Market_desc Region_id Region_desc

Fact Sales - Stores


Lookup Item Item_id Item_desc Class_id Class_desc Dept_id Dept_desc Division_id Division_desc

Item_id Store_id Date Sales_Dollars Sales_Units

Lookup Day Date Month_id Month_desc Year_id

EDUCATION

Why Higher Level Attribute Lookup Tables


Higher level lookup tables provide for more efficient browsing. Higher level lookup tables are what enable the use of aggregate fact tables.
Lookup Division Division_id Division_desc Lookup Region

Fact Sales - Regions Item_id Region_id Date Sales_Dollars Sales_Units

Region_id Region_desc

Lookup Dept Dept_id Dept_desc Division_id Division_desc

Lookup Store Store_id Store_desc Market_id Market_desc Region_id Region_desc

Fact Sales - Stores


Lookup Item Item_id Item_desc Class_id Class_desc Dept_id Dept_desc Division_id Division_desc

Item_id Store_id Date Sales_Dollars Sales_Units

Lookup Day Date Month_id Month_desc Year_id

EDUCATION

Normalized Star Schema Summary


Lookup Division Division_id Division_desc Lookup Dept Dept_id Dept_desc Division_id Division_desc Lookup Region Region_id Region_desc

Fact Sales - Regions Item_id Region_id Date Sales_Dollars Sales_Units


Lookup Store Store_id Store_desc Market_id Market_desc Region_id Region_desc

Lookup Item Item_id Item_desc Class_id Class_desc Dept_id Dept_desc Division_id Division_desc

Fact Sales - Stores Item_id Store_id Date Sales_Dollars Sales_Units

Lookup Day Date Month_id Month_desc Year_id

EDUCATION

The Consolidated Star vs. The Snowflake

vs.

Consolidated Star
Few Tables / Few Joins Easy SQL No support for M:M relationships Limited support for characteristic attributes Inflexible schema Not scalable

Snowflake
More Tables / More Joins More complex SQL M:M is possible Characteristic attributes fully supported Flexible schema Scalable

EDUCATION

Continue Case Study

Continue working on the Case Study.

EDUCATION

Вам также может понравиться