Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a MySQL table as easily as possible 6 35
How to search for strings inside db views 4 25
Mongo DB 18 41
Create snapshot on MSSQL 2012 3 17
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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

776 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