Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-11-25
3
Medium Priority
?
161 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 2000 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 66

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 66

Author Closing Comment

by:Jim Horn
ID: 40549749
Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

971 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