dimenion modelling 2

20
Confidential © L&T Infotech 22 Oct 07 |1 |usha v Dimensional Modeling

Upload: ankit-gupta

Post on 17-Jan-2016

3 views

Category:

Documents


0 download

DESCRIPTION

DM2

TRANSCRIPT

Page 1: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |1 |usha v

Dimensional Modeling

Page 2: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |2 |usha v

• Some basics• Why do we need dimension

modeling?• Difference between ER / DM• How to start?• Four step Dimensional Design• Types of Grains in Fact Table• About the Modeling Techniques• Slowly Changing Dimension• Some Best Practices

Agenda

Page 3: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |3 |usha v

Question the basics

Fact and dimensionsFact Table : It is the primary table where the numeric performance

measures of the business are storedDimension Tables : These are integral companions to a fact table. They

contain textual descriptors of the business.A measure (e.g. sales amount, qty, etc) – It is numeric measurement in a

fact table.Each measure depends on a set of dimensions (e.g. sales volume as a

function of product, time, and location)Each dimension can have a set of associated attributes

• For each dimension, the set of associated attributes can be structured as a hierarchy Normalization and De Normalization

Some Basics

Page 4: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |4 |usha v

Example of measures & attributes

DateMonthYear

Date Dimension

CustIdCustNameCustCityCustCountry

Customer Dimension

Sales Fact Table

Date

Product

Store

Customer

unit_sales

dollar_sales

schilling_sales

ProductNoProdNameProdDescCategoryQOH

Product Dimension

StoreIDCityStateCountryRegion

Store Dimension

Measures

Attributes

Page 5: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |5 |usha v

Examples of dimension hierarchies

StoreStore type

City Region

Customer City State Country

Page 6: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |6 |usha v

• Dimension Modeling • One fact table for

data organization• Maximize

understandability• Optimized for

retrieval• The data

warehousing model• Lesser Joins between

tables when compared with the ER

ER Model• One table per entity• Minimize data

redundancy• Optimize update• The Transaction

Processing Model

ER Modeling vs Dimensional Modeling

Page 7: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |7 |usha v

Identify the

reporting requiremen

t of the client Study the

source tables

Given by the client

Apply the dimensiona

l techniques

Provide the model

Steps leading to modeling

Page 8: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |8 |usha v

Choose the Data Mart Declare the Grain Choose the Dimensions Choose the Facts

Four Step Modeling Process

Page 9: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |9 |usha v

The TRANSACTION grain, -represents a point in space

and time The PERIODIC SNAPSHOT grain, -represents a regular span

of time repeated over and over and The ACCUMULATING SNAPSHOT grain, -represents the entire life of

an entity.

Types of Grains

Page 10: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |10 |usha v

Star Model View• A single object (fact table) in the middle connected to a

number of dimension tables

Snow Flake View• A refinement of star schema where the dimensional

hierarchy is represented explicitly by normalizing the dimension tables

Fact Less Fact View Bridge View

Modeling Techniques

Page 11: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |11 |usha v

Type 1 (Update) Type 2 (New record) Type 3 (New attribute)

Slowly Changing Dimensions

Page 12: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |12 |usha v

Avoid null keys in fact tables Don’t normalize dimension, fact tables Join between dimension and fact tables in

data warehouse should be on surrogate keys ( not operational codes)

Refer Kimball’s Dimensional techniques www.kimball.com

http://www.dbmsmag.com

Best Practices

Page 13: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |13 |usha v

Product_ Dim

Product_IdOther Descriptors Sales Fact

Customer_IdProduct_Id

Representative_IdDate_Id

Quantity_SoldSales_Amount

Date_Dim

Date_IdOther Descriptors

Representative_Dim

Representative_IdOther Descriptors

Customer_Dim

Customer_IdOther Descriptors

Star Model

Page 14: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |14 |usha v

Star Schema with data

customer custId name address city53 joe 10 main sfo81 fred 12 main sfo

111 sally 80 willow la

product prodId name pricep1 bolt 10p2 nut 5

store storeId cityc1 nycc2 sfoc3 la

sale oderId date custId prodId storeId qty amto100 1/7/97 53 p1 c1 1 12o102 2/7/97 53 p2 c1 2 11o105 3/8/97 111 p1 c3 5 50

Page 15: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |15 |usha v

Multidimensional Cube

sale Product Client Date Amtp1 c1 1 12p2 c1 1 11p1 c3 1 50p2 c2 1 8p1 c1 2 44p1 c2 2 4

day 2c1 c2 c3

p1 44 4p2 c1 c2 c3

p1 12 50p2 11 8

day 1

Fact relation 3-dimensional cube

Back

Page 16: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |16 |usha v

Sales Fact

Customer_IdProduct_Id

Representative_IdDate_Id

Quantity_SoldSales_Amount

Customer_Dim

Customer_IdCountry_Id

Other Descriptors

Product_ Dim

Product_IdOther Descriptors

Representative_Dim

Representative_IdOther Descriptors

Date_Dim

Date_IdOther Descriptors

Country_Dim

Country_IdOther Descriptors

Back

Snow Flakes Model

Page 17: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |17 |usha v

Diagnosis Dimension

Diagnosis_KeyDescription

TypeCategory

Patient Billing Fact Table

Date_KeyPatient_KeyDoctor_KeyService_Key

Diagnosis_GroupBilled_Amount

Diagnosis Group Helper Table

Diagnosis_GroupDiagnosis_Key

Weighting factor

Bridge Table

Page 18: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |18 |usha v

Student Course Fact

StudentFacultyBridge_IdStudent_Term_Id

StudentLocationBridge_IdInstitution_Id

Date_Id

Student Course to Faculty_Dim

StudentFacultyBridge_IdFaculty_Id

Other Descriptors

Student_Term_ Dim

Student_Term _IdOther Descriptors

Institution_Dim

Institution_IdOther Descriptors

Date_Dim

Date_IdOther Descriptors

Faculty_Dim

Faculty_IdOther Descriptors

Back

Student Course to Location_Dim

StudentLocationBridge_IdLocation_Id

Other Descriptors

Location_Dim

Location_IdOther Descriptors

Bridge Table (contd.)

Page 19: Dimenion Modelling 2

Confidential © L&T Infotech 22 Oct 07 |19 |usha v

Requirement Fact

Interview Fact

• Status Dim

Date Dim SBU Dim

Candidate Dim

Requirement Dim

Accept/Decline Dim

Source Dim

Technology Dim

Reasons Dim

Interview Dim

Factless Fact

Page 20: Dimenion Modelling 2

Thank You