Solved

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

Posted on 2014-11-25
3
143 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now