Solved

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

Posted on 2014-11-25
3
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

752 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