Skip to content
Advertisement

DB2 : SQL: Change in granularity for SCD type-2 table

I have a order table in SCD type-2 like below (Delivery Date in Order granularity and it create history when when delivery date changes)

Next I have a line table which is also in type-2 line below (it is having history when Quantity changes or description changes)

Now as part of design change Delivery_Dt granularity changes from Order level to Line Item level and in a redesigned Line item table history need to be captured correctly for Line Item level change + Delivery Date change like below

Can this be achieved simply through a SQL statement using the existing Order and Line Item tables ?

I am trying this in DB2 database.

Advertisement

Answer

This could be a solution for you:

There is a brilliant blog about that topic: „Fun with Date Ranges“ by Jon Maenpaa

You can also do that with Db2 Temporal Tables offering time travel SQL in addition.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement