Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 657 | Views in the last 30 days: 4
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones