10.11.2012 Views

Expert Cube Development with Microsoft SQL Server 2008

Expert Cube Development with Microsoft SQL Server 2008

Expert Cube Development with Microsoft SQL Server 2008

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ 27 ]<br />

Chapter 1<br />

Therefore, the conclusion is that although surrogate keys are very useful and we are<br />

not saying that there is something wrong <strong>with</strong> them, in some well-defined situations<br />

it makes sense to deviate from the standard recommendations for surrogate keys and<br />

use different forms instead.<br />

The last consideration is that – even in cases where we deviate from the<br />

standard – the usage of surrogate keys of the smallest integer type possible is always<br />

strongly advised. The Analysis Services engine is optimized for the handling of<br />

integer values and does not handle string and date values anywhere near as well.<br />

Unknown members, key errors, and<br />

NULLability<br />

When designing a data mart, questions often arise about the relationship between<br />

the fact table and the dimensions. Should the foreign keys be NULLable or not?<br />

Should we use the built-in foreign keys of <strong>SQL</strong> <strong>Server</strong> to handle the relationship?<br />

What about key errors?<br />

Since these are very interesting topics, let us discuss them in more detail.<br />

•<br />

•<br />

•<br />

Can we use NULLable foreign keys columns? The answer is definitely no.<br />

If we do, when the data is moved into the cube, there will be no relationship<br />

between the dimension and the facts containing the NULL key, leading to<br />

either processing errors or situations where the user will see partial data. It<br />

is much better to add a new member to the dimension, and relate the facts<br />

<strong>with</strong> missing key values to that member in our ETL. Although the Unknown<br />

Members feature in Analysis Services does this for us, we will have more<br />

flexibility if we handle the issue ourselves.<br />

Should we use <strong>SQL</strong> <strong>Server</strong> FOREIGN KEYS? The correct technique to adopt<br />

here is as follows: we should define the foreign keys in the data model and<br />

activate them during debugging, in order to detect errors. When the system<br />

is in production, the foreign key can be disabled in order to speed up the<br />

ETL code.<br />

Key errors: there should be no key errors at all. If we enable foreign key<br />

checking then we will end up <strong>with</strong> a table <strong>with</strong>out key errors. This is<br />

important: even though we can leverage Analysis Services' key error<br />

handling functionality during processing, we advise not using it because<br />

the presence of a key error should be detected and resolved during the<br />

ETL process, as <strong>with</strong> NULL keys.<br />

Download at Boykma.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!