Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Data Warehouse Version Management

By Les Smith,

Data Warehouse Version Management

In most tables it is enough to have a stored procedure that performs Update Else Insert logic for data managment. However, in some cases we do not want to destroy the old data with an update statement. Instead we want to maintain history up to a certain number of versions. For example a bank may wish to keep records of a customer's address changes. Another classic example mentioned by most data warehouse writers is a name change. A woman gets married and changes her name, but we wish to keep a record of both the current name and the historical name.

We can track this information by having a main ID (an integer) in the table and then another ID for tracking changes (a decimal). In my example we have the integer field, CompanyID and then the dwCompanyID, a decimal. We version from n.10 to n.90. So nine versions of the CompanyID are allowed.

Our example is of a business that needs to track CreditStatus history for the last nine changes.The last version number must always be the most current.

If the CompanyID already has nine records in it the oldest record (CompanyID.10) is dropped, and then all the remaining records (.20 through .90) are decremented by one. Thus we can insert our record and it becomes the ninth version (CompanyID.90).

We also need to check if this is a valid version change. We need to check if the value in the CreditStatus field is actually different from the value held by the latest version. Otherwise we would see a history of a version change even if nothing had changed.

Thus suppose we enter a CreditStatus of 1 for Company 1. First parameter is CompanyID, second is CreditStatus. sp_slowChangeDim 1,1 The table will now look like this.

CompanyID dwCompanyID CreditStatus Date
1 1.10 1 Apr 25 2000 12:21PM

If we entered sp_slowChangeDim 1,1 another time there would be no changes. However, if we change the CreditStatus to 2 using "sp_slowChangeDim 1, 2" we would get a valid new version created.

CompanyID dwCompanyID CreditStatus Date
1 1.10 1 Apr 25 2000 12:21PM
1 1.20 2 Apr 25 2000 12:23PM

Download:

Total article views: 3080 | Views in the last 30 days: -1
 
Related Articles
FORUM

replication with changed records details

replication with changed records details

ARTICLE

Version Control - Part 2 - Tracking Changes

Part 2 of Steve Jones' series on version control. This article examines how you can track the change...

FORUM

dbcc check db changing schema version

consistency check is causing a database schema version change

FORUM

Creating versions of records in tables

Versioning of data

FORUM
Tags
 
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