When are Hubs & Links like Peg-Legged Pirates of Old? And What do composite business keys have to do with Pirate Treasure Gold?
The more I go, the less I like the idea of composite business keys being candidates for Hubs. Here, I present a source system scenario, and explain how it plays out in creating a Data Vault as far as creating Hubs go. In my mind, I can only find a few small instances where composite business keys truly make sense. Perhaps, just maybe, I am leaning towards Anchor modeling for the business keys?
In any case, if you have examples of where you’ve successfully used composite business keys in Hubs, and why the make sense, I’d love to hear from you. Please post your answers below in the comments section.
The Problem (as I see it)
Let’s take an example shall we? Note, this is PseudoCode! Notice the use of business key declaration in the DDL – makes it INVALID as a proper DDL example.
Create Table CONTRACT ( ContractNum int not null, RevisionMum int not null, Business Key (ContractNum, RevisionNum) )
In reality: WHAT does this key represent? and WHAT is the true business key? and WHY is this a problem?
Well, for starters: there can and should be one and only one contract number for the whole system. Just imagine, if there were the same contract numbers assigned to different customers – but because of the revision number, it made it unique!
So: TOM has contract #12345 revision 2, and Mary has contract #12345 revision 5 – totally valid.
Yet from a business standpoint, this *should* be an invalid business case!! Tom and Mary should have separate contract numbers, to be represented properly.
YET: if you look closer, revisionNum is a weak business key. by itself it has no meaning. In other words, revision 5. who has revision 5? what is revision 5? Well, in the data set – any “contract” that has been revised 5 times or more will have a revision number of 5…
So is this a sticky case? Yes. Can it be easily resolved? Not without human intervention.
The Mechanical Solution
For those of you using a tool to generate Data Vaults, the mechanical solution is also sticky, but necessary. There are a series of composite rules that RapidACE v2 follows to produce a much better Data Vault than RapidACE v1. RapidACE V1 splits both fields in to single Hub keys – without regard to anything else. I can’t comment on Quipu, or BI-Ready, because I don’t know what they do in this situation.
In WhereScape, the Human is partly involved in making a decision on structure – which is where this responsibility should lie.
(By the way, there is a POST on LinkedIn, asking about this very condition – using different fields)
SO: the mechanical solution: to produce what is given to you – with a number of different rules guiding the production of Hubs. If you want to see the results of these rules, then you will have to use RapidACE v2 SaaS (when made public) in order to do it. Signing up to be a paying SaaS customer will provide you with the User Guide where the examples are documented in detail.
For the short answer: RapidACE v2 would *most likely* produce this set of fields as a single composite Hub.
The Manual Answer:
IF you are doing this manually, then I would suggest you examine the rest of the model – and ask yourself the following questions:
- is “your field” (like RevisionNum) a dependent child? If so, then most likely it will become a composite Hub
- Do you have a need or requirement to have a unique list of Contract Numbers? If so, then you might break the Hub out for Contract Number, then: (here’s the odd part), you would end up with a link that houses contract Sequence and Revision Number – since Revision Number is weak – you wouldn’t model a Hub for it. This would lead to a peg-legged link.
Ahoy there Matey!
Anyhow, the satellite (if there are additional fields in the table) would hang from the peg-legged link if you decided to create one. Otherwise, if you use a composite business key Hub, then the satellite would hang from it.
When to Break Apart Composite BK’s
Sometimes it is necessary to break apart the business keys, especially if they are smart keys; and this is where we start to go down the path of 6th normal form, or Anchor Modeling. However the trade-off (there is always a trade-off) is that you end up with more joins and more tables, but if you’ve switched to a K=V, Triple Store, or Columnar datastore, then this will not matter to you – because your DV model will become more logical control over your structures anyhow.
Now, if you can or want to buy in to the trade-off -then a funny thing can happen: The more parts of the data model that rely on THAT key, the more likely that Satellites can fold their relationship and hang from that instance of the Hub. Meaning “less overall join tables”…. BUT be careful… the more composite keys that exist in the model, the more link tables will be formed.
smart key = where the entire key is broken in to segments, and each segment has meaning.
What’s our Heading Captain?
Well, the compass points North (at least for now), and what it says is this:
IF the composite Business Key is not a part of any foreign key (meaning it has no “parents”) then, it shall remain intact as a composite business key in the Hub, rather than fishing around for additional link tables and catching a whale of a tale!
IF you decide that there is value in breaking it up, then do so – just realize you might end up with a peg-legged link!
What are your thoughts? comments? Love to hear from you.
PS: you can read all about degenerate or weak business keys/child dependent keys in my book: Super Charge Your EDW which you can get here: http://LearnDataVault.com/purchase-book