Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NULL key in fact table or NULL row in dimension?? 1

Status
Not open for further replies.

etistudent

Technical User
Jan 5, 2005
4
PL
Hi!

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 ETL project performance or maybe better for future queries to warehouse??
 
In a star schema design, it is preferable to create a specific surrogate key (such as -1) for nulls. Then create a "null" customer in the customer dimension with key value -1 and a "null" vendor with key value -1 (or -2 or whatever) in the vendor dimension. I like to use negative key values for purposes such as this to easily distinguish it from other keys.

-------------------------
The trouble with doing something right the first time is that noboby appreciates how difficult it was.
- Steven Wright
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top