DWH Temporality Part 2: Reducing Complexity
About "Temporality" in the Data Vault
Getting rid of the temporal complexity
As the manufacturer of the Datavault Builder automation software, we are frequently asked how to map the changes over time in our tool and/or in the Data Vault in general. Often in the form of: how can I report SCD Type 2 stuff. However, it is sometimes not clear which time axis we are talking about. Therefore, here is an attempt to clarify this. This is the second article in a series of three.
-
The first article defined the challenge we are facing with temporality in the DWH
-
This article defines possibilities to simplify the temporal complexity if possible
-
The third article discusses business requirements to output timelines
-
The fourth article will explain how to technically output the 3d timeline as SCD type 2
There are different approaches to temporality in the data vault. I would, therefore, recommend reading the texts by Dirk Lerner, Christian Kaul, and Lars Rönnbäck. I present here a variant of how to represent or simplify the various time lines in such a way that they can be brought under control. I will also publish a follow-up article on what to do if such a simplification is not possible because the business requirements demand more options. As defined in the first article I’m discussing only 3 time lines and I use the following shortcuts:
-
1d for Valid Time
-
2d for Inscription Time
-
3d for Load Time
What are we talking about / corrections vs. real history
True history vs. relevant history
How to model 1d history in the DWH *3
What about relevant dimensional attributes: instantiation
Even though I have described above that certain changes of attributes are not relevant for many evaluations, there are certainly such changes which are central. An example is one of our customers who has the possibility to produce or buy certain products himself before he sells them to his customers. For quality assurance purposes, it is significant whether the product was sold and delivered by the customer or by an external company. Of course, the right way would be for the source system to already record this information. Unfortunately, in this case, the setting in the Product Master System at the time of ordering is the only source of this information. This setting is therefore not historized or instantiated in the source. Therefore, we have to use the 3d history as the best approximation. So, we have the case where a 3d time axis is used as an approximation for the 1d view. If we now stay with the classic Kimball modeling, we would output a sales order line as “fact”. In this case the product characteristics would be output as SCD type 2 “dimension”. Since we do not have a 1d time axis here, the 3d time axis would be used for the SCD type 2 historization and a Valid From and Valid To would be calculated based on this. Again I think using the labels valid from and to for the 3d axis will create confusion so try to omit this. However, other product attributes, such as the product name, should be output without history, since changes to these attributes normally correspond to a correction. This means that the dimension would be transferred to the report once in an SCD type 2 version and once in an SCD type 1 (as-of-now) version. In fact, we now have to include two foreign keys: the business key itself plus the business key combined with the correct time slice - which is often represented by a surrogate key in a Kimball world.
This means additional complexity in the report and additional complexity in creating the fact. Although it now looks as if we could combine different time views, this is usually not the case: the name in this example is always read as-now (as-of-now) and the product property is always read as-then (as-of-then) *5. So what is a simple solution that allows the same analyses in the report, but is simple for modeling the data mart/report view? In Data Vault modeling, there is a very simple way to do this: we can transfer this attribute from the product hub to the sales order line hub. This is done by setting up a Business Vault Load at the time the transaction is loaded into the Raw Vault, which does an as-of-now lookup on the product attribute and then stores it in a Business Vault satellite on the transaction. It’s trivial because we don’t have to do any historical queries on the 3D axis and it’s efficient because we only have to do it for new transactions. The only objection could be that this materialization consumes storage space. But this is not really a problem with databases that support columnar storage, because the few instances of such attributes are compressed anyway. I call this procedure instantiation of an attribute on another grain.*8 3rd simplification / strategy : instantiate attributes at a certain point in time to the transactions
Short summary
With these three simplifications / strategies,
-
storing 2d just as an attribute in the satellite
-
inclusion of the 1d time in the hub key
-
instantiation of attributes on the transaction
I claim we can cover most of the requirements for a historicized output in most industries. In a third article, I will discuss the cases where this is not sufficient and what are the technical solutions for such requirements. Footnotes *1 The example with Basel as the place of residence is completely invented - of course, I would never consider living in Basel, just as no “Basler” would consider living in Zurich as far as this can be prevented. *2 Again, special reports are excluded: if, for example, I want to evaluate the quality of data entry in the source system, such name changes may, of course, be relevant. *3 Can also be used analogously for 3d history if it is used as an approximation for 1d. *4 The problem that several MA satellites cannot be connected without special rules, because otherwise a cross product is created, I do not deal with in detail, because with the special subtype of the bi-temporal satellite you can find an automated pattern to cross out the entries correctly, if you capture the time/date fields in the metadata. *5: you can also map the whole thing differently by linking only the as-then (as-of-then) dimension in the fact and then making a self-link on the dimension itself for the as-now (as-of-now) values. This is not supported by certain reporting tools like QlikView etc. But the main reason why I didn’t list this variant is that it doesn’t make the report simpler in my opinion, but more complicated. *7 I took this expression from some ETH professors in Zurich who write mathematical formulas on the two-room wide blackboard and explain them at the end, just because it is deterministic, it is trivial *8 here I like to be instructed if there is a more suitable / clearer expression
See Datavault Builder in action
Great, pick a time that works for you: