3

I have a star schema that tracks Roles in a company, e.g. what dept the role is under, the employee assigned to the role, when they started, when/if they finished up and left.

I have two time dimensions, StartedDate & EndDate. While a role is active, the end date is null in the source system. In the star schema i set any null end dates to 31/12/2099, which is a dimension member i added manually.

Im working out the best way to update the Enddate for when a role finishes or an employee leaves.

Right now im:

  1. Populating the fact table as normal, doing lookups on all dimensions.

  2. i then do a lookup against the fact table to find duplicates, but not including the EndDate in this lookup. non matched rows are new and so inserted into the fact table.

  3. matching rows then go into a conditional split to check if the currentEndDate is different from the newEnd Date. If different, they are inserted into an updateStaging table and a proc is run to update the fact tableFact table data flow

Is there a more efficient or tidier way to do this?

JD_Sudz
  • 194
  • 1
  • 12

2 Answers2

0

How about putting all that in a foreach container, it would iterate through and be much more efficient.

DrHouseofSQL
  • 550
  • 5
  • 16
  • I dont understand, i cant see how a for each container helps optimize the workflow, or how it fits in at all. can i ask for a bit more detail please. Thanks! – JD_Sudz Feb 17 '16 at 15:16
0

I think it is a reasonable solution. I personally would use a Stored Proc instead for processing efficiency, but with your dimensional nature of the DWH and implied type 2 nature, this is a valid way to do it.

The other way, is to do your "no match" leg of the SSIS as is, but in your "match" leg, you could insert the row into the actual fact table, then have a post process T-SQL step which would update the two records needed.

Marcus D
  • 1,074
  • 1
  • 12
  • 27