Hi!
This is not strictly DS question but maybe someone had similar situation.
Let's say we have two dimensions: customer and vendor, and one fact table with columns: customer_id, vendor_id and value.
In one row in fact table we can have reference to customer dim or vendor dim (never to both of them).
Is it better to put in customer and vendor dim row with NULLs in all columns and put into facts foregin key indicates to it
or
put into fact table NULL or "0" (foregin key indicates to nothing) as vendor or customer foregin key??
Is one of theese solutions better for DS project performance or maybe better for future queries to warehouse??
NULL in fact table as FK or ....
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Re: NULL in fact table as FK or ....
Personaly I would have the fact table with two columns an ID column and a fact column. On the Ref table I would have a flag that would indicate Client or Vender. I say this becuase having Nulls in a FK relationship is not the best thing you can do for perforamace. I have seen databases handle Null in very odd ways. But thats just a DBA's thoughts on the mater.Luk wrote:Hi!
This is not strictly DS question but maybe someone had similar situation.
Let's say we have two dimensions: customer and vendor, and one fact table with columns: customer_id, vendor_id and value.
In one row in fact table we can have reference to customer dim or vendor dim (never to both of them).
Is it better to put in customer and vendor dim row with NULLs in all columns and put into facts foregin key indicates to it
or
put into fact table NULL or "0" (foregin key indicates to nothing) as vendor or customer foregin key??
Is one of theese solutions better for DS project performance or maybe better for future queries to warehouse??
Sure I need help....But who dosent?