Friday, May 2, 2014

Fact and Dimension Examples

A fact table works with dimension tables. A fact table holds the data to be analyzed, and a dimension table stores data about the ways in which the data in the fact table can be analyzed. Thus, the fact table consists of two types of columns. The foreign keys column allows joins with dimension tables, and the measures columns contain the data that is being analyzed.
Suppose that a company sells products to customers. Every sale is a fact that happens, and the fact table is used to record these facts. For example:
 Fact Table Example:
Time IDProduct IDCustomer IDUnit Sold
41721
82132
8411
 Now we can add a dimension table about customers:
 Dimension Table Examples:

Customer Dimension

Customer ID
Name
Gender
Income
Education
Region
1Brian EdgeM234
2Fred SmithM351
3Sally JonesF173
 Date Dimension
Time ID
DateKey
Date_UK
Date_USA
DayofMonth
DayName
12013010101/01/201301/01/20131Tuesday
22013010202/01/201302/01/20132Wednesday
32013010303/01/201303/01/20133Thursday
  Product Dimension
Product ID
Product Name
Product Business Key
Batch ID
Category
Group
1Aero MilkAC-3AA1DairyDairy
2Bikky RiceBK-B342FoodCereals
3Bikky BicsBZ-CG52BiscuitsCookies
In this example, the customer ID column in the fact table is the foreign key that joins with the dimension table. By following the links, you can see that row 2 of the fact table records the fact that customer 3, Sally Jones, bought two items on day 8. The company would also have a product table and a time table to determine what Sally bought and exactly when.
When building fact tables, there are physical and data limits. The ultimate size of the object as well as access paths should be considered. Adding indexes can help with both. However, from a logical design perspective, there should be no restrictions. Tables should be built based on current and future requirements, ensuring that there is as much flexibility as possible built into the design to allow for future enhancements without having to rebuild the data.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.