Durable keys¶
What is a durable key?¶
A durable key is an unchanging identifier that is used to represent an entity regardless of changing attributes. A durable key can either be a surrogate key or a natural key. Within bframe, durable keys are used to allow for continuity between model amendments.
Why are durable keys important?¶
Durable keys are important for type 2 slowly changing dimensions (SCDs). As an entity changes over time the durable key is the only field that is immutable. Since type 2 SCDs create additional rows the durable key allows for each additional change to be identified as the entity. Within bframe, type 2 SCDs depend on the immutability of the durable key to function. For example, to amend a contract an additional row would be created with the necessary changes. In this case the id
, effective_at
and ineffective_at
fields would change but the durable_key
would stay the same. Below is an example of what this could look like in practice.
id |
durable_key |
started_at |
ended_at |
effective_at |
ineffective_at |
---|---|---|---|---|---|
1323 |
Auntof6_contract |
2023-11-01 00:00:00 |
2024-11-01 00:00:00 |
2023-11-01 00:00:00 |
2024-06-01 00:00:00 |
100011 |
Auntof6_contract |
2023-11-01 00:00:00 |
2024-11-01 00:00:00 |
2024-06-01 00:00:00 |
How are durable keys modeled in bframe?¶
The durable key should be set in the durable_key
field. A surrogate key can be used to represent the durable key or a natural key. Durable keys are considered immutable and should only be updated with caution.