Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Slowly Changing Facts Expand / Collapse
Author
Message
Posted Friday, October 18, 2013 3:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 5, 2014 10:11 AM
Points: 7, Visits: 33

Please please please refer to these sorts of articles as 'techniques' or 'methods' or 'solutions' -valuable mind you, but 'design pattern' mens something quite specific, and strategies for using sql and related tools ain't it

A minor point, but not everything is a 'design pattern', nor does it need to be to be useful.

Just trying to prevent more abuse of the language...
Post #1506034
Posted Friday, October 18, 2013 7:19 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
Rexell (12/13/2012)
Can you let me know if you know of any other legitimate reasons for implementing this solution or of any other potential pitfalls you may have seen when implementing it in the past please? Thanks.

I can tell you this kind of type 1 and type 2 transactional fact table data update collection is so popular now that M$ put CDC into SQL 2008 to make it easier to track and load into Data Warehouses and what I like to call Data Audit Warehouses.
Of course most anyone that is not the lead DBA or in executive management will see the goodness the provides.
Post #1506147
Posted Friday, October 18, 2013 7:20 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
markoos1 - Great article. That is all
Post #1506151
Posted Friday, October 18, 2013 7:25 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
psychodba (4/17/2012)
I dont see any easy way to maintain AVG measures in this model. We need two layers of aggregations.
SUM to construct the full amount and only then AVG. This is not possible for some applications.

In what way do you see this? Sorry but I cant see your point.
Post #1506155
Posted Friday, October 18, 2013 10:33 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 28, 2014 7:12 PM
Points: 2,148, Visits: 487
Good article.

There is no "right" or "wrong" way to handle this; however, this methodology (ledgering changes) has two main advantages:

1. Complete auditability and data transparency.
2. Allows for incremental processing of multidimensional Analysis Services cubes instead of an expensive full reprocessing of a cube.

No solution is without risk.

Steven Neumersky, CBIP, MCITP
Post #1506263
Posted Friday, October 18, 2013 10:36 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
sneumersky (10/18/2013)

2. Allows for incremental processing of multidimensional Analysis Services cubes instead of an expensive full reprocessing of a cube.

It is obvious you have been there and come back with knowledge.
Thank you for sharing!
Post #1506265
Posted Friday, October 18, 2013 10:39 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
jcraigue@cox.net (10/18/2013)

A minor point, but not everything is a 'design pattern', nor does it need to be to be useful.
Just trying to prevent more abuse of the language...

Design Pattern has to be the new red headed step child of Software Architecture Language. It seems to be abused and used in the wrong way more than "Extreme Application Development".
Post #1506268
Posted Friday, October 18, 2013 1:21 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, October 28, 2013 1:51 PM
Points: 2, Visits: 8
Let's assume we don't use SCD2 on the fact table.
ID SalesPersonID ProductID SaleMonth Quantity Revenue
1 101 1001 2012-01 10 100
2 101 1002 2012-01 4 64
3 101 1003 2012-01 3 36

Then we bring the table to some Reporting tool like BO, OBIEE, Cognos.
We define the aggregates:
SUM(Revenue) Revenue_SUM,
AVG(Revenue) Revenue_AVG

Now users can design the report by grabbing these elements:
SalesPersonID, SaleMonth, Revenue_Revenue_SUM, Revenue_AVG
This will be the average of all sales per Month and Person.

Reporting tool will generate a query like this:
SELECT SalesPersonID, ProductID, SaleMonth, SUM(Revenue), AVG(Revenue)
FROM fact.SalesDetail
GROUP BY SalesPersonID, ProductID, SaleMonth.

Statistics: 3 deals, 3 products, total quantity 17
Revenue_SUM will be (100+64+36) =200
Revenue_AVG will be (100+64+36)/3 =66.67


Now, let's assume there was a mistake in the source and it's corrected with SCD2.
ID SalesPersonID ProductID SaleMonth Quantity Revenue Audit SourceID
1 101 1001 2012-01 20 200 1 1
2 101 1002 2012-01 4 64 1 2
3 101 1003 2012-01 3 36 1 3
4 101 1001 2012-01 -10 -100 2 1


Statistics: 3 deals, 3 products, total quantity 17
Revenue_SUM will be (200-100+64+36) =200
Revenue_AVG will be (200-100+64+36)/4 =50

It's all the same, but AVG is wrong.

Well, it's still possible to figure out some of these aggregates.
For Revenue_AVG would be:
SUM(Revenue) / (COUNT(*) - COUNT(DISTINCT Audit) +1)

Would you be able to write one to show the MIN (Revenue) ?
In this case you need to SUM first to get the full amounts and only then do the MIN.
This is not doable using Reporting GUI for ordinary users.

I don't even dare to think of some more complicated analytical functions here like RunningTotals and etc.
Luckily there are other better solutions.
Post #1506320
Posted Monday, October 28, 2013 1:48 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, October 28, 2013 2:34 PM
Points: 17, Visits: 31
This topic itself is nice and the techniques mentioned in this article can be used in many occasions.

However "change a dimension ID to see what happens" section does not cover the situation when the staging fact table already has a transaction (record) with same sale person id , product id and date.

The following update statement will create a record with a duplicate key (100, 1004, 20101102), if allowed.

UPDATE staging.SalesDetailSource
SET SalesPersonID = 100
WHERE ProductID = 1004
AND SalesPersonID = 101
AND SaleDate = 20101102;

Any explanation on how to handle this situation will be interesting.

Thanks.
Post #1509101
Posted Monday, October 28, 2013 1:59 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 29, 2014 6:43 AM
Points: 335, Visits: 299
scrrbiswas (10/28/2013)
This topic itself is nice and the techniques mentioned in this article can be used in many occasions.

However "change a dimension ID to see what happens" section does not cover the situation when the staging fact table already has a transaction (record) with same sale person id , product id and date.

The following update statement will create a record with a duplicate key (100, 1004, 20101102), if allowed.

UPDATE staging.SalesDetailSource
SET SalesPersonID = 100
WHERE ProductID = 1004
AND SalesPersonID = 101
AND SaleDate = 20101102;

Any explanation on how to handle this situation will be interesting.

Thanks.

Depends on if you want a Historical record for this dimension table update.
Is this just a situation where you want to update the Business Key Id in the dim table when it changes in the source?
Maybe some details on what is a Suragate Key and a Business Key in your statement above?
You are using Suragate keys in your Dimension tables right?
Post #1509105
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse