Choice of Effective Range Representation
The effective range interval and the method and the predicate used to identify a version are closely linked. The two most common approaches to interval representation are:
Closed Interval Method
The boundaries of the effective range are inclusive. The predicate determining effective versions as of time T is "T between T1 and T2" where T1 and T2 are the two values denoting the beginning and end of each version. Although this makes it simpler for the query-writer, it introduces complexity on the maintenance side. If one version ends at time T1 then the next version must begin at time T1 + 1 day. For cases where the versioning grain is a different unit - hour, minute, millisecond etc. then the next version must begin at time T1 + 1 hour or T1 + 1 minute, or T1 + 1 millisecond respectively. And a variable versioning grain (unlikely for most business applications) intrduces even more complexity.
Semi-closed Interval Method
The effective begin time of the range is inclusive, while the end time is non-inclusive. The predicate determining effective versions as of T is "T >= T1 and T < T2" where T1 and T2 are the two values denoting the beginning and end of each version. Another option is to add a condition to the original predicate: "T between T1 and T2 and T <> T2." This approach makes maintenance simpler because the same value is used for the beginning time of a version and the ending time of the predecessor version. When a new version is created there is no calculation involved to determine the closing value of the prior effective range. This is true always regardless of versioning grain.
- Log in to post comments