Solved

SSIS 2008 : Need some advice where source is Type 1 SCD and stores as Type 2 SCD

Posted on 2014-11-25
3
153 Views
Last Modified: 2016-02-11
Hi All

Points for any constructive advise on an SSIS project I have where the source is a Type 1 SCD, and desired target is SQL Server that stores the data as Type 2 SCD.

Source
Salesforce.com (SF) data, PK’s are columns id (int) and SystemModstamp (datetime) columns, and the data is stored as a Type 1 SCD, which means If a value changes in a row then it will have the same id, but different SystemModstamp, and whatever other changes.  No history is kept.

My Requirements
Client wants see…
•      (Requirement #1, aka R1) Only the current row (i.e. same as source)
•      (R2) All history for a given row, which means I have to build that up on my own based on changes over time.

My Table / Views Design
•      ‘Staging’ table as an initial landing for all source data.  No problems on this one.
•      A single table for each SF table, with all rows (to include changes as new rows),   Also includes a CurrentRow (bit) column with a value of 1 if current row and 0 if not current.
•      (R1) will be a view that is a SELECT * FROM above table
•      (R2) will be a view that is a SELECT * FROM above table WHERE current_row = 1
•      Indexed on id, SystemModstamp, and CurrentRow.

My SSIS Package Design
•      Truncate ‘staging’ tables, load with SF source data.
•      Then in a single data flow…
o      INSERT all rows (with current_rows = 1) without a match in id
o      INSERT all rows (with current rows = 0) with a match in id, and no match in SystemModstamp.
o      Run a SQL Stored Procedure to look at the rows with multiple SystemModstamp values for a given id, update the max to 1, all else 0.   This I can code, so no problem.

Again, points for any constructive feedback.

Thanks.
Jim
0
Comment
Question by:Jim Horn
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40465420
I would have a bit more auditing.

Have Start Date and End Date as columns for your SCD 2, so you can trace where a row changes. I know you have the SystemModstamp, but it might make things easier - your call. Also, a column as to when a row was imported, so if your source data has an error, you can trace all rows entered then.

Do you need a new primary key for the SCD 2. And should it be non-clustered, so you can use your index as a clustered index?

What is the end result going to be used for? If mostly used for queries where CurrentRow = 1, then you might want the index to be on CurrentRow, then id etc.

Just some thoughts.
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 0 total points
ID: 40465505
>Have Start Date and End Date as columns for your SCD 2, so you can trace where a row changes
Thanks.  Just dawned on me that instead of doing the WHERE CurrentRow = 1, I can always do WHERE SystemModstamp_End IS NULL and get the same result without all of the mechanics of populating a new column CurrentRow.

>Do you need a new primary key for the SCD 2.
id + Systemmodstamp will work fine as the PK.

>And should it be non-clustered, so you can use your index as a clustered index?
Probably could, as all SystemModstamp values will be data entry as of that day.  
Haven't thought about CLUSTERED vs. NON-CLUSTERED.

>What is the end result going to be used for?
All the current downstream reporting matches the source (my role is to add history to the current process), so yes an index on that value would be ideal.
0
 
LVL 65

Author Closing Comment

by:Jim Horn
ID: 40549749
Thanks.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Software for Local History Museum Library 5 53
SSRS Deployment problem 5 67
changing page verifacation 1 32
MS SQL SERVER and ADODB.commands 8 23
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question