Group 5 Detailed-Level-Dimensional-Modeling-Workbook-Group5

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 48

The Microsoft Data Warehouse Toolkit 2008 R2

Dimensional Modeling Workbook

Date:
Database:
Description:
Version:
Gen FKs?:
Schema for Views:

= Fact

= Dimension

= Utility Table

© copyright 2005-2011, Kimball Group, all rights reserved


t Data Warehouse Toolkit 2008 R2
Modeling Workbook

Friday, February 19, 2016


NorthwindDW
The Northwind Traders Datawarehouse
1.00
Y

How to use this tool:


1) Copy the BlankDim and BlankFact worksheets and fill them in with appropriate dimension and fact table information
2) Change the database name above to the name of the target database to which you would like to write this dimensional mode
3) Make sure macros are enabled, and select the Create/Update Diagram(s) button to see a simple bubble diagram of your mo
4) Select the Generate SQL Script button to generate a script you can use to create your database
(This is the "forward engineer" button.)
5) See the ReadMe sheet for additional information
= Fact Generate SQL Script
= Dimension
Create/Update
= Utility Table Diagram(s)

011, Kimball Group, all rights reserved


Notes about this Excel workbook and macro
On the first ("Home") sheet of this workbook, you can see two buttons. The button titled "Generate SQL Script" starts an Exc
generate a SQL script for the tables described in the workbook. The button titled "Create/Update Diagram(s)" starts an Excel
worksheet for each fact table (if it doesn't already exist), and creates a simple "bubble" diagram of the model.

Some notes follow:

- The process of generating a script does nothing in your database. It simply generates a script into a new worksheet at the e

- We're not "Real Programmers," so there is not a huge quantity of error checking in the macros, and there are definitely no g
save your workbook before generating the script.

- You can use this workbook and macro to generate an arbitrary SQL Server database. Here are some instructions and rules

o To use this tool, first go to the Home worksheet and enter the overall database information.
o Next, make a copy of the BlankDim or BlankFact worksheet for each dimension or fact table you'd like to create.
o Name each worksheet according to the display name of the table it defines.
o Delete the example entries in each sheet and fill in the table and column names, definitions, etc. for your tables.
o Change the "N" to "Y" in the Generate Script? field if you want the macro to include the table in the script.
o The "Key?" column takes the following values: PK (Primary Key), ID (Identity), FK (Foreign Key). You can combine PK ID to
generated surrogate key for a dimension.
o The "FK To" column holds the table and column reference to the primary key of the table to which this entry is a foreign key
(tablename.columnname).
o The table header rows at the top of each worksheet get instantiated as table-level extended properties.
o Add rows to that area in order to add information that you'd like to be additional table extended properties.
o Leave a blank line before the Column Information section.
o We'll create extended properties for each column starting with DisplayName (until we see an empty cell in that header row)
o The diagram generator looks for the fact tables, then uses the foreign key definitions to find the associated dimension table
o Be sure to fill in the display name for a better looking diagram
o Once you create a diagram, you can click on each table in the diagram and it will link you back to the table's worksheet
(this only works if the worksheet name matches the display name of its table, otherwise, the links are invalid)

The Home sheet in this workbook is for general information and navigation purposes.
erate SQL Script" starts an Excel macro that will
te Diagram(s)" starts an Excel macro that adds a
m of the model.

t into a new worksheet at the end of this workbook.

s, and there are definitely no guarantees. You should

re some instructions and rules:

you'd like to create.

etc. for your tables.


in the script.
Key). You can combine PK ID to indicate a database

which this entry is a foreign key

properties.
ed properties.

empty cell in that header row).


he associated dimension tables

ck to the table's worksheet


links are invalid)
Date Change # Version # Person
7/2/2011 16 4.0 JM

16/2/2009 15 3.4 JM

15/1/2009 14 3.4 JM

11/6/2008 13 3.3 WT
20/5/2008 12 3.3 WT

4/4/2008 11 3.2 WT
16/11/2007 10 3.2 WT
10/8/2006 9 WT
7/8/2006 8 WT
25/7/2006 7 WT

25/7/2006 6 WT
13/7/2006 5 WT
18/5/2006 4 JM
11/1/2006 3 JM
30/8/2005 2 WT
30/8/2005 1 WT
Description
Confirmed for SQL2008R2. Fixed many small bugs, including FK generation. Added user-oriented
views that use the display names. Made it prettier.
Changed char and varchar datatypes to nchar / nvarchar almost everywhere. Added a few
transaction IDs that are useful in the ETL process.
Translated to Excel 2007. Translated to SQL 2008. Changed database recovery mode to simple.
Simplified audit dimension.
Added a macro to convert version 3.2 worksheets into version 3.3
Added the ability to specify an optional schema level in the table names and removed spurious
references to the word schema.
Updated bubble diagram generator to include fact table column name in all role playing dims
Removed the SET IDENTITY INSERT commands for tables that do not have an IDENTITY
column
Added code to allow the Audit dimension to be identified as an Audit Table Type rather than a
dimension.
Updated the instructions
Added a Description for the overall database on the Schemas page and set the macro to
overwrite the extended property if the Description already exists.
Added a Display Name field at the attribute level
Added the bubble diagram generator
Oops. Fixed parentheses error that showed up (for whatever reason) in non-US locales.
Fixed FK generation error
Removed Region Alternate Hierarchy, added Sales Region to Customer
Added Change Log tab
Table Name DimAudit
Table Type Audit Home Page
Display Name Audit
Database Schema
Table Description Audit dimension tags each data row with the the process that added or updated it.
Comment The Audit dimension keeps track of each execution branch of your Integration Services packages. By
Biz Filter Logic
Size one row per execution of a package
Generate Script? Y

Column Name Display Name Description Unknown


Member

AuditKey AuditKey Surrogate primary key -1


ParentAuditKey ParentAuditKey Foreign key to self, to identify calling package -1
execution
TableName TableName Name of the main table loaded by this package Audit
PkgName PkgName Name of the SSIS package None: Dummy row
PkgGUID PkgGUID Identifier for the package
PkgVersionGUID PkgVersionGUID Identifier for the package version
PkgVersionMajor PkgVersionMajor Major version number for the package
PkgVersionMinor PkgVersionMinor Minor version number for the package
ExecStartDT ExecStartDT Date-time the package started executing
ExecStopDT ExecStopDT Date-time the package finished executing
ExecutionInstanceGUID ExecutionInstanceGUID Identifier for the execution of the package
ExtractRowCnt ExtractRowCnt Count of rows extracted from the source(s)
InsertRowCnt InsertRowCnt Count of rows inserted in the destination table
UpdateRowCnt UpdateRowCnt Count of rows updated in the destination table
ErrorRowCnt ErrorRowCnt Count of error rows
TableInitialRowCnt TableInitialRowCnt Count of rows in target table before we begin
TableFinalRowCnt TableFinalRowCnt Count of rows in target table after package ends
TableMaxSurrogateKey TableMaxSurrogateKey Maximum surrogate key value in table (if we're
maintaining ourselves)
SuccessfulProcessingInd SuccessfulProcessingInd Did the package finish executing successfully? Y
ded or updated it.
our Integration Services packages. By properly maintaining the audit structure, you can determine which package -- and which branch of ea

Example Values SCD Display Folder ETL Rules


Type

1, 2, 3…
1, 2, 3…

None: Dummy row

Y, N
determine which package -- and which branch of each package -- loaded (or updated) data in the data warehouse tables. And, when that p

Target
Comments Datatype Size Precision Key? FK To NULL?

int PK ID N
int FK DimAudit.AuditKey N

nvarchar 50 N
nvarchar 50 N
uniqueidentifier Y
uniqueidentifier Y
smallint Y
smallint Y
datetime N
datetime Y
uniqueidentifier Y
bigint Y
bigint Y
bigint Y
bigint Y
bigint Y
bigint Y
bigint Y

nchar 1 N
arehouse tables. And, when that package was executed.

Source
Default Value Source Source Schema Source Table Source Field Name Source
System Datatype

Derived
Derived

Unknown
Unknown

getdate()

N
Table Name DimCustomer
Table Type Dimension Home Page
Display Name Customer
Database Schema
Table Description Customers Dimensions
Comment comes from customers table in nopCommerce
Biz Filter Logic
Size one for each row
Generate Script? Y

Column Name Display Name Description Unknown


Member

CustomerKey CustomerKey Surrogate primary key -1


CustomerID CustomerID Business key from source system (aka natural
key)
Username Username Customer's username
Email Email Customer's email
Active Active Is the customer active
Deleted Deleted Is the customer account deleted?
CustomerAddress CustomerAddress Customer's address
Customer Name CustomerName Customer's Name
Company Company Customer's company name
City City Customer's city
ZipPostalCode ZipPostalCode Customer's postal code
Country Country Customer's Country
RowIsCurrent Row Is Current Is this the current row for this member (Y/N)? Y
RowStartDate Row Start Date When did this row become valid for this member? 31/12/1899
RowEndDate Row End Date When did this row become invalid? (12/31/9999 if 31/12/9999
current row)
RowChangeReason Row Change Reason Why did the row change last? N/A
InsertAuditKey InsertAuditKey What process loaded this row? -1
UpdateAuditKey UpdateAuditKey What process most recently updated this row? -1
Example Values SCD Display Folder ETL Rules
Type

1, 2, 3… key
ALFKI key
[email protected] 2
[email protected] 2
1 2
0 2
Dilli, Syracuse, United States 2
Richa Malhotra 2
Reebok 2
Syracuse 2
13210 2
USA 2
Y, N n/a Exclude from cube Standard SCD-2
24/1/2011 n/a Exclude from cube Standard SCD-2
1/14/1998, 12/31/9999 n/a Exclude from cube Standard SCD-2

n/a Exclude from cube Standard SCD-2


n/a Exclude from cube Standard Audit dim
n/a Exclude from cube Standard Audit dim
Target
Comments Datatype Size Precision Key? FK To NULL?

int PK ID N
int 5 N
nvarchar 1000
nvarchar 1000
bit N
bit N
nvarchar 1002 N
nvarchar 1000
nvarchar 1000
nvarchar 1000
nvarchar 100

bit N
datetime N
datetime N

nvarchar 200 N
int FK DimAudit.AuditKey N
int FK DimAudit.AuditKey N
Source
Default Value Source System Source Schema Source Table Source Field Name Source
Datatype

Derived
group5-nopCommerce dbo Customer Id int
group5-nopCommerce dbo Customer Username nvarchar
group5-nopCommerce dbo Customer Email nvarchar
group5-nopCommerce dbo Customer Active bit
group5-nopCommerce dbo Customer Deleted bit
Derived
Derived
group5-nopCommerce dbo Address Company nvarchar
group5-nopCommerce dbo Address City nvarchar
group5-nopCommerce dbo Address ZipPostalCode nvarchar

1 Derived
12/31/1899 Derived
31/12/9999 Derived

N/A Derived
Derived
Derived
Table Name DimProduct
Table Type Dimension
Display Name Product
Database Schema
Table Description Product Dimension
Comment comes from product table in nopCommerce
Biz Filter Logic
Size one for each row
Generate Script? N

Column Name Display Name

ProductKey ProductKey
ProductID ProductID
ProductName ProductName
ProductCategory ProductCategory
ProductShortDescription ProductShortDescription
RowIsCurrent Row Is Current
RowStartDate Row Start Date
RowEndDate Row End Date

RowChangeReason Row Change Reason


InsertAuditKey InsertAuditKey
UpdateAuditKey UpdateAuditKey
Home Page

Description Unknown Example Values SCD Display Folder


Member Type

Surrogate primary key -1 1, 2, 3… key


Business key from source system (aka natural 1, 2, 3… key
key)
Product's Name Ikura 2
Product's Category Camera 2
Product's Short Description Digital Storm Vanquish 3 2
Is this the current row for this member (Y/N)? Y Desktop
Y, N PC n/a Exclude from cube
When did this row become valid for this member? 31/12/1899 24/1/2011 n/a Exclude from cube
When did this row become invalid? (12/31/9999 if 31/12/9999 1/14/1998, 12/31/9999 n/a Exclude from cube
current row)
Why did the row change last? N/A n/a Exclude from cube
What process loaded this row? -1 n/a Exclude from cube
What process most recently updated this row? -1 n/a Exclude from cube

Comments
This is the template for a dimension table. Use the "Move or Copy Sheet" choice on the Edit menu to make a
of this sheet before you make any changes to it. Be sure to check the "Create a Copy" box in the dialog box.

Usage notes:
- The Key? Column is PK, FK, or PK ID. Make sure you set the NULL? column to N for a PK column.
- Don't re-order the columns, unless you want to mess with the macro.
- The table and column "Comments" fields are not added as extended properties. Extended properties are lim
to 128 characters.
Target
ETL Rules Comments Datatype Size Precision

int
int
nvarchar 400
nvarchar 400
nvarchar 1000
Standard SCD-2 nchar 1
Standard SCD-2 datetime
Standard SCD-2 datetime

Standard SCD-2 nvarchar 200


Standard Audit dim int
Standard Audit dim int

et" choice on the Edit menu to make a copy


"Create a Copy" box in the dialog box.

column to N for a PK column.

properties. Extended properties are limited


Target Source
Key? FK To NULL? Default Value Source System Source Schema Source Table

PK ID N Derived
N group5-nopCommerce dbo Products
N group5-nopCommerce dbo Products
N group5-nopCommerce dbo Category
N group5-nopCommerce dbo Products
N Derived
N 12/31/1899 Derived
N 31/12/9999 Derived

N N/A Derived
FK DimAudit.AuditKey N Derived
FK DimAudit.AuditKey N Derived
ce
Source Field Name Source
Datatype

ProductID int
ProductName nvarchar
Name nvarchar
ShortDescription nvarchar
Table Name DimStore
Table Type Dimension Home Page
Display Name Product
Database Schema
Table Description Product Dimension
Comment comes from storetable in group5-nopCommerce
Biz Filter Logic
Size one for each row
Generate Script? N

Column Name Display Name Description Unknown


Member

StoreKey StoreKey Surrogate primary key -1


StoreID StoreID Business key from source system (aka natural
StoreName StoreName key)
Name of store
CompayName CompayName Name of company
CompanyAddress CompanyAddress Address of company
CompanyPhoneNumber CompanyPhoneNumber Contact details of company
RowIsCurrent Row Is Current Is this the current row for this member (Y/N)? Y
RowStartDate Row Start Date When did this row become valid for this member? 31/12/1899
RowEndDate Row End Date When did this row become invalid? (12/31/9999 if 31/12/9999
current row)
RowChangeReason Row Change Reason Why did the row change last? N/A
InsertAuditKey InsertAuditKey What process loaded this row? -1
UpdateAuditKey UpdateAuditKey What process most recently updated this row? -1

Comments
This is the template for a dimension table. Use the "Move o
of this sheet before you make any changes to it. Be sure to

Usage notes:
- The Key? Column is PK, FK, or PK ID. Make sure you set
- Don't re-order the columns, unless you want to mess with t
- The table and column "Comments" fields are not added as
128 characters.
Example Values SCD Display Folder ETL Rules
Type

1, 2, 3… key
1, 2, 3… key
Grabys 2
1 ,2 ,3… 2
1020 Westcott , 13210 Syracuse, NY 2
3159351147 2
Y, N n/a Exclude from cube Standard SCD-2
24/1/2011 n/a Exclude from cube Standard SCD-2
1/14/1998, 12/31/9999 n/a Exclude from cube Standard SCD-2

n/a Exclude from cube Standard SCD-2


n/a Exclude from cube Standard Audit dim
n/a Exclude from cube Standard Audit dim

a dimension table. Use the "Move or Copy Sheet" choice on the Edit menu to make a copy
make any changes to it. Be sure to check the "Create a Copy" box in the dialog box.

K, FK, or PK ID. Make sure you set the NULL? column to N for a PK column.
mns, unless you want to mess with the macro.
"Comments" fields are not added as extended properties. Extended properties are limited to
Target
Comments Datatype Size Precision Key? FK To NULL?

int PK ID N
int N
nvarchar 400 N
nvarchar 1000 N
nvarchar 1000 N
nvarchar 1000 N
nchar 1 N
datetime N
datetime N

nvarchar 200 N
int FK DimAudit.AuditKey N
int FK DimAudit.AuditKey N
Source
Default Value Source System Source Schema Source Table Source Field Name Source
Datatype

Derived
group5-nopCommerce dbo Store ID int
group5-nopCommerce dbo Store Name nvarchar
group5-nopCommerce dbo Store CompayName nvarchar
group5-nopCommerce dbo Store CompanyAddress nvarchar
group5-nopCommerce dbo Store CompanyPhoneNumber nvarchar
Derived
12/31/1899 Derived
31/12/9999 Derived

N/A Derived
Derived
Derived
Table Name OrderFact
Table Type Fact
Display Name Blank Fact
Database Schema
Table Description Orders Fact Table
Comment
Biz Filter Logic
Size
Generate Script? N

Column Name Display Name

StoreKey StoreKey
ProductKey ProductKey
CustomerKey CustomerKey
OrderID OrderID
OrderItemID OrderItemID
ProductTotalPrice ProductTotalPrice
ProductDiscountPercent ProductDiscountPercent
OrderDateKey OrderDateKey
QuantityOrdered QuantityOrdered
ProductDiscount OrderDiscount
InsertAuditKey InsertAuditKey
UpdateAuditKey UpdateAuditKey
Home Page

Description Unknown Member Example Values

Key to Store Dimension 1, 2, 3…


Key to Product Dimension 1, 2, 3…
Key to Customer Dimension 1, 2, 3…
Degenerate Dimensions from Order Table 1, 2, 3…
Degenerate Dimensions from Order Table 1,2,3
Total Price of products 353
Discount percent on the products 50
Order Date from Order Dimension 1996-07-04 00:00:00.000
Total quantity of the Orders placed from Order Item Table 1, 2, 3…
Discount allowed on the order placed from Order Table 0
Key to Audit dimension for row insertion 1, 2, 3
Key to Audit dimension for row update -2 1, 2, 3
Display Folder ETL Rules Comments Datatype

key int
key int
key int
int

int

key datetime
int

key Standard auditing


key Standard auditing
Target Source
Size Precision Key? FK To NULL? Default Value Source Source Schema Source Table
System
FK DimStore.StoreKey N ETL Process
FK DimProduct.ProductKey N ETL Process
FK DimCustomer.CustomerKey N ETL Process
N

FK DimDate.DateKey N ETL Process


N
Source
Source Field Name Source
Datatype
Table Name ReviewFact
Table Type Fact Home Page
Display Name Blank Fact
Database Schema
Table Description Review Fact Table
Comment
Biz Filter Logic
Size
Generate Script? Y

Column Name Display Name Description Example Values

ProductKey ProductKey Key to Product 1, 2, 3

InsertAuditKey Insert Audit Key Key to Audit dimension for row insertion 1, 2, 3
UpdateAuditKey Update Audit Key Key to Audit dimension for row update 1, 2, 3
AverageProductRating AverageProductRating Always add a description! 4.4
TotalRatings TotalRatings Total number of reviews 10
TotalApprovedRatings TotalApprovedRatings Total Approved reviews 6
TotalDisApprovedRatings TotalDisApprovedRatings Total disapproved reviews 2
TotalHelpfulYesCount TotalHelpfulYesCount Number of customers who found the reviews 8
TotalHelpfulNoCount TotalHelpfulNoCount helpful
Number of customers who did not find the reviews 2
helpful
Display Folder ETL Rules Comments Datatype

key int

key Standard auditing int


key Standard auditing int
Amount decimal
Counts & rates int
Counts & rates int
Counts & rates int
Counts & rates int
Counts & rates int
Target Source
Size Precision Key? FK To NULL? Default Value Source Source Schema Source Table
System
FK Product.ProductKey N ETL Process

FK DimAudit.AuditKey N ETL Process


FK DimAudit.AuditKey N ETL Process
18,1 Y
Y
Y
Y
Y
Y
Source
Source Field Name Source
Datatype

You might also like