blw-ofag-ufag / eCH-0261

eCH-0261 -- Agrardaten - Betriebs- und Unternehmensstammdaten
1 stars 0 forks source link

Proposed Standardised Element "Validity" #19

Closed montanajava closed 7 months ago

montanajava commented 7 months ago

validityProposal.xlsx

Since domain versioning is a ever-recurring requirement, it makes sense to standardise and thereby simplify the usage thereof.

Requirements:

As is evident from the above, this proposal is non-judgmental as to the approach chosen by architects in the implementation if a given service.

This proposal is for "Domain" versioning only and does not preclude technical versioning in any way.

The proposed elements contained herein are:

validFromInclusive (xs:date | xs: dateTimestamp)m not null Supports the concept of entry of a domain object into circulation or usage. validFromExclusive (xs:date | xs:dateTimeStamp) nullable, default 9999-12-12 , nullable. Supports the concept of removal of a domain object from circulation. iteration xs:postiveInteger, nullable

A few words of explanation as to the proposed elements:

See the following referenced white paper from IBM Temporal Data Management for a lucid argument in support of this approach, specifically the section Inclusive-inclusive or inclusive-exclusive time periods:

https://public.dhe.ibm.com/ps/products/db2/info/devWorks_pdfs/Best_practices/DB2BP_Temporal_Data_Management_1012.pdf

Example of conundrum with validToInclusive select * from crop where validToInclusive =< '2004-04-12T23:59:59Z' // will potentially miss a value based on the precision of the value.

Example of Clean Query with validToExclusive select * from crop where validToInclusive < '2004-04-13' // will deterministically return all eintries that up to and including the previous day.

If put into this standard, then this and the other standards (0261 - 0267) should be updated to use this.

AFoletti commented 7 months ago

My 2 cents on this proposal:

  1. I think shifting to exclusive for validTo is the right choice and I support the change.
  2. I am unsure about the notion and usefulness of "iteration". Properly versioning objects is in my opinion not something so easily solved. Starting from the principle that this is only useful for what you called "mutable" objects (since by definition immutable do not have iterations) I will try to explain my rationale.

image This is the same object but its validity is shifted forwards in time. However, you now potentially have other (older) objects from other classes linked to this object (via its ID) that are now potentially "wrong" since they are meant to use the 2024 version (which does not exist anymore). It may be correct (e.g. a simple correction of the validFrom) but we cannot be sure. I would avoid this situation if possible.

image Basically the same as above

image This only works if the actual object's ID is compounded from ID and the version. I would honestly avoid that since all the references to objects are only done via IDs (which is in my opinion correct) and this will make such easy pointing impossible. In other words: if someone makes a reference to object 123, how to I know which version does he mean?

I think that if we really need to track versions of objects we should treat everything as immutable and integrate a way to point to the object being replaced. E.g.:

objectId: 100
validFrom: 2024-01-01
validUntil: 2025-01-01

objectId: 200
validFrom: 2025-01-01
validUntil: 2026-01-01
replacesId: 100

Such a construct still freely allows for overlapping versions of the same "thing". The question is if we really need it ot not

montanajava commented 7 months ago

Ok. Taking Ambogio's input, the solution (based on a real-world implementation) could look like this:

Image

We thus would

montanajava commented 7 months ago

Document that this is intended as a domain-specific validity range and is not a replacement for a technical Version attribute.

montanajava commented 7 months ago

explicitly document that ValidityType is only sensible for immutable objects. If dealing with a mutable object, a version or iteration attirbute should be additionally applied.

lars-steffen commented 7 months ago

implemented with #25