Best Praticte for inserting fact and linking to dimensions
Page 1 of 1 • Share •
Best Praticte for inserting fact and linking to dimensions
Hi all,
is it allowed to have null values in fact table for some dimensions foreign keys ?
Exemple :
DateDimFk DimFk1 DimFk2 50 (coming from business system 1)
DateDimFk null DimFk2 50 (coming from business system 2)
or do i have to create a special dimension data row (for instance "?") to link these facts ?
Many thanks in advance.
Best Regards.
is it allowed to have null values in fact table for some dimensions foreign keys ?
Exemple :
DateDimFk DimFk1 DimFk2 50 (coming from business system 1)
DateDimFk null DimFk2 50 (coming from business system 2)
or do i have to create a special dimension data row (for instance "?") to link these facts ?
Many thanks in advance.
Best Regards.
bmoraillon- Posts: 12
Join date: 2010-06-06
Re: Best Praticte for inserting fact and linking to dimensions
Null foreign keys in fact tables is very bad practice. Always populate the key and reference a 'not applicable' row. Queries that have joins where an FK may be null will exclude those rows from the query, even if you are not filtering on a value in that dimension.

ngalemmo- Posts: 1732
Join date: 2009-05-15
Location: Los Angeles

Re: Best Praticte for inserting fact and linking to dimensions
ngalemmo wrote:Null foreign keys in fact tables is very bad practice. Always populate the key and reference a 'not applicable' row. Queries that have joins where an FK may be null will exclude those rows from the query, even if you are not filtering on a value in that dimension.
Thank you very much !
bmoraillon- Posts: 12
Join date: 2010-06-06
Re: Best Praticte for inserting fact and linking to dimensions
It's common to use -1 as the default value for a dimension key value in the fact table. Add a row to each dimension table with -1 as it's surrogate key value. I would populate the columns for this "null" row with "NA", Not Applicable", "missing", etc., whatever is appropriate (Nulls in a column that is being filtered are a drag).
Jeff Smith- Posts: 311
Join date: 2009-02-03
Similar topics» Best Praticte for inserting fact and linking to dimensions
» Date Columns in FACT or Dimensions
» Data Modelling -- linking Header and Detail Fact Tables.
» Linking or Merging Similar dimensions from Different Source Systems
» Dimensions Directly Tied to Facts vs. Snowflaking
» Date Columns in FACT or Dimensions
» Data Modelling -- linking Header and Detail Fact Tables.
» Linking or Merging Similar dimensions from Different Source Systems
» Dimensions Directly Tied to Facts vs. Snowflaking
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum