Skip to main content

Mandatory subrecord

There must always be exactly one of this type of subrecord that is live for the full lifetime of the record.

This means that:

  • There must be at least one of this subrecord
  • There must be at least one subrecord with a start date equal to the start date of the record
  • Every subrecord must have a unique start date
  • The start date of the subrecord must be before or equal to the end date of the record

Because validity rules are applied at the end of a transaction, this rule requires the first subrecord to be created in the same transaction as the record.

If the record is updated to move the start date earlier, the start date of the first subrecord must be moved earlier in the same transaction or a new subrecord introduced to cover the new period.

If the record is updated to move the start date later, the start date of the first subrecord must be moved later in the same transaction or the first subrecord deleted if a later subrecord covers the new start date.

This rule ensures that the subrecord in question always has a unambiguous value for as long as the record is live. This is used when the subrecord represents some mandatory property of the record that can change over time.

Example

A footnote description is a mandatory subrecord for a footnote.

If a footnote is created in transaction 1 and a footnote description is created in transaction 2, then transaction 1 would fail this rule. If both the footnote and footnote description are created in transaction 1, then it would pass this rule.

If a footnote is created with validity start 2021-01-01 and a footnote description record is created with validity start 2021-02-01 then the transaction will fail this rule because the footnote exists for 1 month without a footnote description. If the footnote description is created with validity start 2020-12-01 then this rule would still fail because the footnote description is live for 1 month before the footnote. To pass the rule, the footnote description and footnote need to have the same 2021-01-01 start date.

If the footnote is updated to start 2021-02-01 but the footnote description is not changed, then the update transaction would fail this rule because the footnote description is again live before the footnote.

If a second footnote description is added with the same start date of 2021-01-01 then the transaction will fail this rule because the two footnote descriptions start at the same moment. If the second description starts a day later on 2021-01-02 then this rule will pass.

If the footnote is updated to also have a validity end date of 2021-01-01 (so it is live for one day) then the transaction will fail because the second footnote now starts after the end date of the footnote. If the second footnote is deleted in the same transaction, then this rule will pass.

Test data

In this test data each row represents a transaction. Each transaction builds on the data added in previous transactions that have passed the validity rule. Transactions that have failed the validity rule are not persisted and do not affect later transactions.

# Foonote First description Second description Pass/fail
1 Created, starting 2021-01-01 Fail - no description
2 Created, starting 2021-01-01 Created, starting 2021-02-01 Fail - period with no description
3 Created, starting 2021-01-01 Created, starting 2020-12-01 Fail - description live before footnote
4 Created, starting 2021-01-01 Created, starting 2021-01-01 Pass
5 Updated, starting 2021-02-01 No change Fail - description live before footnote
6 Updated, starting 2021-02-01 Updated, starting 2021-02-01 Pass
7 No change No change Created, starting 2021-01-01 Fail - two descriptions with same date
8 No change No change Created, starting 2021-02-01 Pass
9 Updated, ending 2021-01-01 No change No change Fail - description live after footnote
10 Updated, ending 2021-01-01 No change Deleted Pass