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_id`` would stay the same. Below is an example of what this could look like in practice. .. csv-table:: Contracts :file: /_static/ex_tables/ex_m4_1.csv :class: bmodel-table :header-rows: 1 How are durable keys modeled in bframe? ======================================= The durable key should be set in the ``durable_id`` 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.