Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Enforcing surrogate key uniqueness in slowly changing dimension

By Federico Iori,

In datawarehouse slowly changing dimension with surrogate key are often used. It may happen, because of ETL poorly designed or other reasons, that ETL loads record not correctly versioned, violating the rule "for each unique value of the natural key there should be only one value of the surrogate key". 

It would be nice to define a database constraint to enforce such an uniqueness , in Sql Server is not intuitive but is possible using a clustered unique index defined on an indexed view , defined as aggregate select.

In practice, the indexed view let us define an unique constraint based on aggregate select .

Total article views: 698 | Views in the last 30 days: 3
 
Related Articles
FORUM

indexes (non-unique,clustered)

indexes (non-unique,clustered)

BLOG

Unique/Non-Unique Clustered Indexes

In the last blog post I have talked about unique/non-unique clustered indexes on a heap table. A ta...

FORUM

Unique index in sql server 2005

Unique index in sql server 2005

FORUM

unique clustered index on 2 columns

unique clustered index on 2 columns

BLOG

Unique and non-unique non-clustered indexes on a unique clustered index

In the last weblog post I have talked about the difference of unique and non-unique clustered indexe...

Tags
dimension    
dwh    
indexed views    
natural key    
scd    
surrogate key    
 
Contribute