dbTalk Databases Forums  

Fact Table and Dimension Design question

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Fact Table and Dimension Design question in the microsoft.public.sqlserver.olap forum.



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

Default Fact Table and Dimension Design question - 03-03-2004 , 02:32 AM






Hi OLAP Gurus,
I am designing cube with the snowflake model ( attached below are the
samples of the tables ) :
Questions are :
(1) should I have PK on Fact Table ?
If Yes, then If I have e.g:10 dimension then my PK will have 10 key
column ?
(2) Should I have Index on each FK column on Fact Table ?
(3) On Product_Dim : should I have Index on ProductCategoryId and SupplierId
?

Thanks for your help,
Krist

SalesFact :
------------
DateId (FK to Time_Dim)
ProductId (FK to Product_Dim)
CustomerId (FK to Customer_Dim)
SalesAmt
Qty

Time_Dim : Product_Dim : Customer_Dim :
------------- -------------- ---------------
DateId ProductId CustomerId
Year ProductName CustomerName
Month ProductCategoryId
Day SupplierId

* ProductCategoryId and SupplierId will be snowflaked to ProductCategory
table and Supplier table.





Reply With Quote
  #2  
Old   
Tilfried Weissenberger
 
Posts: n/a

Default Re: Fact Table and Dimension Design question - 03-03-2004 , 05:03 AM






Hi Tristant,

Quote:
(1) should I have PK on Fact Table ?
usually do should - if it makes sense from a database-perspective.

Quote:
If Yes, then If I have e.g:10 dimension then my PK will have 10 key
column ?
what do you mean by that? your dimensions could all/also be based on the
fact-table. So the number of keys (I think you mean relations) to other
tables has nothing to do with the number of dimensions

Quote:
(2) Should I have Index on each FK column on Fact Table ?
You place an index on columns which occur in (but not limited to) WHERE or
JOIN/ON clause. So that's something you have to decide. Also - indexes are
not always the best thing - if, for example, the table is updated very
frequently.

Quote:
(3) On Product_Dim : should I have Index on ProductCategoryId and
SupplierId
in my opinion (please someone correct me if I'm wrong): AS retrieves all
records on a table anyways - so indexes won't help you in that case. AS
builds it's own keys internally and manages that, so indexes really only
help if you use VIEWS as a base for the cube and you filter records in them.

regards, Tilli




Reply With Quote
  #3  
Old   
Ray Higdon
 
Posts: n/a

Default Re: Fact Table and Dimension Design question - 03-03-2004 , 05:09 AM



First of all I would use surrogate keys, it looks like you are using natural
keys. I typically do put a column in the fact table with the IDENTITY
property. A lot depends on the storage mode you are using for the cube. Keep
in mind that if you are using MOLAP, your indexes will not speed up querying
the cube but will speed up the processing of that cube. However, those
indexes will slow down your ETL work. If you are using the recommended
MOLAP, I would not index any other column besides your FK links (and again,
only to speed processing)

HTH

See this link for good info on cube performance -
http://www.microsoft.com/technet/pro.../ansvcspg.mspx

--
Ray Higdon MCSE, MCDBA, CCNA
---
"tristant" <krislioe (AT) cbn (DOT) net.id> wrote

Quote:
Hi OLAP Gurus,
I am designing cube with the snowflake model ( attached below are the
samples of the tables ) :
Questions are :
(1) should I have PK on Fact Table ?
If Yes, then If I have e.g:10 dimension then my PK will have 10 key
column ?
(2) Should I have Index on each FK column on Fact Table ?
(3) On Product_Dim : should I have Index on ProductCategoryId and
SupplierId
?

Thanks for your help,
Krist

SalesFact :
------------
DateId (FK to Time_Dim)
ProductId (FK to Product_Dim)
CustomerId (FK to Customer_Dim)
SalesAmt
Qty

Time_Dim : Product_Dim : Customer_Dim :
------------- -------------- ---------------
DateId ProductId CustomerId
Year ProductName CustomerName
Month ProductCategoryId
Day SupplierId

* ProductCategoryId and SupplierId will be snowflaked to ProductCategory
table and Supplier table.







Reply With Quote
  #4  
Old   
tristant
 
Posts: n/a

Default Re: Fact Table and Dimension Design question - 03-04-2004 , 03:29 AM



Hi Ray, Thanks for the reply.
Now I am considering using Surrogate key ,
- Do you mean PK of the Fact Table is the Identity column ? What if the
records in fact table has the possibility of not only
inserted but also Updated ? (e.g, due to fluctuation of foreign exchange)
- And PK of the Dimension tables also all are on Surrogate key ?

Thanks,
Krist

"Ray Higdon" <sqlhigdon (AT) nospam (DOT) yahoo.com> wrote

Quote:
First of all I would use surrogate keys, it looks like you are using
natural
keys. I typically do put a column in the fact table with the IDENTITY
property. A lot depends on the storage mode you are using for the cube.
Keep
in mind that if you are using MOLAP, your indexes will not speed up
querying
the cube but will speed up the processing of that cube. However, those
indexes will slow down your ETL work. If you are using the recommended
MOLAP, I would not index any other column besides your FK links (and
again,
only to speed processing)

HTH

See this link for good info on cube performance -

http://www.microsoft.com/technet/pro.../ansvcspg.mspx

--
Ray Higdon MCSE, MCDBA, CCNA
---
"tristant" <krislioe (AT) cbn (DOT) net.id> wrote in message
news:eIrW%23rPAEHA.576 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Hi OLAP Gurus,
I am designing cube with the snowflake model ( attached below are the
samples of the tables ) :
Questions are :
(1) should I have PK on Fact Table ?
If Yes, then If I have e.g:10 dimension then my PK will have 10 key
column ?
(2) Should I have Index on each FK column on Fact Table ?
(3) On Product_Dim : should I have Index on ProductCategoryId and
SupplierId
?

Thanks for your help,
Krist

SalesFact :
------------
DateId (FK to Time_Dim)
ProductId (FK to Product_Dim)
CustomerId (FK to Customer_Dim)
SalesAmt
Qty

Time_Dim : Product_Dim : Customer_Dim :
------------- -------------- ---------------
DateId ProductId CustomerId
Year ProductName CustomerName
Month ProductCategoryId
Day SupplierId

* ProductCategoryId and SupplierId will be snowflaked to ProductCategory
table and Supplier table.









Reply With Quote
  #5  
Old   
Ray Higdon
 
Posts: n/a

Default Re: Fact Table and Dimension Design question - 03-04-2004 , 04:51 AM



Good questions. You typically would have a stage fact table that has all
your natural keys first then translate it to having all surrogate keys. This
way in your ETL you are updating or inserting into facts and dims based on
their natural keys.

Quote:
- Do you mean PK of the Fact Table is the Identity column ? What if the
records in fact table has the possibility of not only
inserted but also Updated ? (e.g, due to fluctuation of foreign
exchange)
Yes, but like above, your update lookups or logic would be done prior to the
final fact table creation

Quote:
- And PK of the Dimension tables also all are on Surrogate key ?
Yes, faster joins with fact and dims thereby allowing faster processing of
cubes and smaller cubes as well.

For design questions no one is better than Ralph Kimball, see this link
http://www.ralphkimball.com/html/articles.html

--
Ray Higdon MCSE, MCDBA, CCNA
---
"tristant" <krislioe (AT) cbn (DOT) net.id> wrote

Quote:
Hi Ray, Thanks for the reply.
Now I am considering using Surrogate key ,
- Do you mean PK of the Fact Table is the Identity column ? What if the
records in fact table has the possibility of not only
inserted but also Updated ? (e.g, due to fluctuation of foreign
exchange)
- And PK of the Dimension tables also all are on Surrogate key ?

Thanks,
Krist

"Ray Higdon" <sqlhigdon (AT) nospam (DOT) yahoo.com> wrote in message
news:Omv8S8QAEHA.1792 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
First of all I would use surrogate keys, it looks like you are using
natural
keys. I typically do put a column in the fact table with the IDENTITY
property. A lot depends on the storage mode you are using for the cube.
Keep
in mind that if you are using MOLAP, your indexes will not speed up
querying
the cube but will speed up the processing of that cube. However, those
indexes will slow down your ETL work. If you are using the recommended
MOLAP, I would not index any other column besides your FK links (and
again,
only to speed processing)

HTH

See this link for good info on cube performance -


http://www.microsoft.com/technet/pro.../ansvcspg.mspx

--
Ray Higdon MCSE, MCDBA, CCNA
---
"tristant" <krislioe (AT) cbn (DOT) net.id> wrote in message
news:eIrW%23rPAEHA.576 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Hi OLAP Gurus,
I am designing cube with the snowflake model ( attached below are the
samples of the tables ) :
Questions are :
(1) should I have PK on Fact Table ?
If Yes, then If I have e.g:10 dimension then my PK will have 10
key
column ?
(2) Should I have Index on each FK column on Fact Table ?
(3) On Product_Dim : should I have Index on ProductCategoryId and
SupplierId
?

Thanks for your help,
Krist

SalesFact :
------------
DateId (FK to Time_Dim)
ProductId (FK to Product_Dim)
CustomerId (FK to Customer_Dim)
SalesAmt
Qty

Time_Dim : Product_Dim : Customer_Dim :
------------- -------------- ---------------
DateId ProductId CustomerId
Year ProductName CustomerName
Month ProductCategoryId
Day SupplierId

* ProductCategoryId and SupplierId will be snowflaked to
ProductCategory
table and Supplier table.











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.