dbTalk Databases Forums  

PK for Fact Table

comp.databases.olap comp.databases.olap


Discuss PK for Fact Table in the comp.databases.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dataman
 
Posts: n/a

Default PK for Fact Table - 07-30-2006 , 04:44 PM






I don't think I need one of these. Do you know of any
reason why I should build and maintain one?

Reply With Quote
  #2  
Old   
Myles.Matheson (AT) gmail (DOT) com
 
Posts: n/a

Default Re: PK for Fact Table - 08-01-2006 , 03:20 AM






Hello DataMan,

I am one for having a PK in the fact table. The PK enforces the grain
(lowest level) of your fact table. This stops the loading of duplicates
into your fact table.

The PK is also used to in force the referential integrity of the data
relationships between the fact table and the dimensions.

Its all about trusting the data is correct in your fact table.

A good mark of a star schema is to have referential integrity enforced.
This guarantees that every fact record has a corresponding dimension
record.

Of course you will have to handle unknown dimension keys this where the
fact table has a record that does not exist in the dimension. I usually
create a dimension record as unknown and allocate it to fact table
surrogate key for that dimension.

Most OLAP engines check this as a test before building the OLAP cube.
In the case of Microsoft Analysis Services an error will be raised if a
fact record has a dimension key that does not exist in the dimension.

I hope this helps,

Myles Matheson
Data Warehouse Architect
http://bi-on-sql-server.blogspot.com/


Reply With Quote
  #3  
Old   
dataman
 
Posts: n/a

Default Re: PK for Fact Table - 08-01-2006 , 08:35 AM



Quote:
Hello DataMan,

I am one for having a PK in the fact table. The PK
enforces the grain (lowest level) of your fact table. This
stops the loading of duplicates into your fact table.

The PK is also used to in force the referential integrity
of the data relationships between the fact table and the
dimensions.
Its all about trusting the data is correct in your fact
table.
A good mark of a star schema is to have referential
integrity enforced. This guarantees that every fact record
has a corresponding dimension record.

Of course you will have to handle unknown dimension keys
this where the fact table has a record that does not exist
in the dimension. I usually create a dimension record as
unknown and allocate it to fact table surrogate key for
that dimension.
Most OLAP engines check this as a test before building the
OLAP cube. In the case of Microsoft Analysis Services an
error will be raised if a fact record has a dimension key
that does not exist in the dimension.
I hope this helps,

Myles Matheson
Data Warehouse Architect
http://bi-on-sql-server.blogspot.com/

Thanks for the feedback. I've not actually ever been able
to convince anyone to turn on the RI for a dimensional
model. "Too much overhead" is the most common complaint.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.