Dimensional Modeling (II)
Dimensional Modeling (II)
14
1
Dimensional Modeling
Build around the numerical
measurements of the business
- Fact tables contain measurements
- Dimension tables contain the
context surrounding measurements
- Measurements are taken at the
intersection of all dimensions
- List of dimensions defines the grain
of the fact table
DATE
15
15
Fact Table
Is the primary table in a dimensional model
Holds the measurements of the business
Composed by a set of foreign keys that connect to
the dimension tables
Its primary key is made up by the set or a subset
of the foreign keys
16
16
2
Fact Table doesn’t store “non-events”
Very important not to try to fill the fact table with
zeros representing “nothing happened”
- If there is no sales activity on a given day, in a given store, for
a given product, the record must be left out of the fact table
17
17
month
week
Product
brands
categories
CUSTOMER
Region
Fact by:
day
date
product
Customer
customer
18
18
3
Dimension Tables
Define the details of each transaction
19
19
Dimension Tables
Provide the context for fact tables, that is, the
context for all the measures
20
20
4
Dimension Attributes
Serve as the primary source of query constraints,
groupings, and report labels
21
21
Surrogate Keys
Joins between dimensions and fact tables should be
based on meaningless integer surrogate keys
- Other names: integer keys, no natural keys, artificial keys,
synthetic keys
Benefits:
- Performance advantages
- Protects the DW from operational changes
- Allow the integration of data from multiple operational source
systems
22
22
5
The Grocery Store
23
24
24
6
Kimball Dimensional Modeling Steps
1.Identify the business process
- Business process is a major operational process supported by
some computational system(s) from which data can be
collected for the purpose of data warehousing (e.g.: orders)
25
26
7
Modelling Grocery Store Business
3. Dimensions involved
- Date
- Product
- Store
- Promotion
4. Facts/Measures of interest
- Value sold
- Units sold
- Sales cost
- Sales profit
- Sales margin
27
27
Date Dimension
Date dimension is present in every DW, because every DW is a
time series
Date Dimension
date-key
full-date
day-week Unlike almost all the other
day-number-month
day-number-year dimensions, date
week-number dimension can be built
month-name in advance – five or ten
month-number
semester year of history records can
quarter be loaded, as well the next
year few years
last-day-month-flag
season
…
28
28
8
Product Dimension
Product dimension describes every SKU with as many descriptive
attributes as possible, including the existing hierarchies
Product Dimension
product-key
SKU-description
SKU-number
package-size
brand
subcategory
category
department
package-type
diet-type
weight
weight-unit
…
29
Store Dimension
Store dimension describes every store in the grocery chain –
geographic dimension
Store Dimension
store-key
store-name
store-number
store-address
store-zip
store-city
store-district
store-region
store-manager
open-date
last-remodel-date
store-sqft Numeric attributes,
grocery-sqft
…
however they are clearly a
constant attribute of store
30
30
9
Promotion Dimension
Promotion dimension – describes each promotion condition
under which a product is sold in the grocery chain
Causal dimension – describes factors that cause a change in
product sales
Needs a special register ”N/A” to join sales in fact table
without promotion
Promotion Dimension
promotion-key
promotion-name
price-reduction-type
ad-type
display-type
coupon-type
ad-media-name
display-provider
promo-cost
promo-begin-date
promo-end-date
…
31
31
Fact Table
32
32
10
Grocery Store Business Schema
Sales Fact
date-key Product Dimension
Date Dimension
product-key product-key
date-key store-key …
… promotion-key
value-sold
units-sold
sales-cost
Store Dimension sales-profit
Promotion Dimension
store-key
promotion-key
…
…
Advantages:
- Easy to understand
- Better performance
- Easy extensible: new dimensions and new facts
33
33
11