14. Allen Relationship and Other Queries
Allen Relationship Queries313
Time Period to Time Period Queries316
Point in Time to Period of Time Queries333
Point in Time to Point in Time Queries341
A Claims Processing Example343
In Other Words346
Glossary References347
In this chapter, we examine each of the thirteen Allen relationships, as well as each non-leaf node in the taxonomy of Allen relationships which we introduced in Chapter 3. We describe the Allen relationships as they hold between two time periods, between a time period and a point in time, and also between two points in time. We show how these relationships are expressed in terms of time periods represented with the closed-open convention, and we provide a sample query for each one.
After a section in which we illustrate how much simpler these queries would be to express if we had a PERIOD datatype, we conclude this chapter by discussing queries which involve temporal joins.
Figure 14.1 shows our taxonomy of the Allen relationships. Those relationships are the leaf nodes in this taxonomy. Every leaf node has an inverse relationship, except the [equals] relationship. We italicize that relationship name to emphasize that it has no inverse. So counting the [equals] relationship, and the six leaf nodes and their inverses, we have the full set of thirteen Allen relationships. We also underline the non-leaf node relationships in the taxonomy, to emphasize that they are relationships we have defined, and are not one of the Allen relationships.
B9780123750419000145/f14-01-9780123750419.jpg is missing
Figure 14.1
The Asserted Versioning Allen Relationship Taxonomy.
Many of the Allen relationships are used by the AVF to enforce TEI and TRI. For example, as we pointed out in Chapter 3, the [intersects] relationship is important because it defines TEI. If two asserted versions of the same object share even a single effective time clock tick, within shared assertion time, then they [intersect], and violate TEI. Otherwise, they don't. The [fills] relationship is important because it defines TRI. If a TRI relationship fails, it is because there is no episode of the referenced parent object which temporally includes, i.e. [fills−1], that of the child version. The [before] relationship is important because it distinguishes episodes from one another. Every episode of an object is non-contiguous with every other episode of the same object, and so one of them must be [before] the other.
As for queries issued by business users, we have found that many ad hoc queries, and perhaps the majority of them, are queries about episodes, not about versions. That is, they are queries that want (i) the begin and end date of the episode and, for business data, (ii) the last version of past episodes, the current version of current episodes, or the latest version of future episodes. Because of the importance of episodes to queries, the SQL examples in this chapter will select episodes. The last, current or latest version contains the business data. The episode begin date that is on every version, and the version's own effective end date, provide the effective time period of the episode itself.
We also note that the SQL in many of the following examples does not represent typical queries that a business would write. Each of these queries focuses on one specific Allen relationship, and show how to express it in SQL. In particular, these sample queries do not include typical join criteria. Instead, the only join criteria used in these examples are two time periods and the Allen relationship between them.
Another reason these sample queries don't look very real world is that they select from two of the tables in our sample database that don't have much to do with one another. In particular, there is no TRI relationship between them. They are the Policy and Wellness Program tables. If we had used, for example, the Client and Policy tables instead, many of the queries would have been more realistic.
But TRI-related tables cannot illustrate all of the Allen relationships. In fact, every instance of a TRI relationship involves a parent and a child time period that is an instance of one of seven of the Allen relationships. This leaves six other Allen relationships that TRI-related tables cannot illustrate.
Nevertheless, as overly simple and unrealistic as most of these sample queries may be, they are the foundation for all queries that express temporal relationships. No query will ever need to express a temporal relationship that is not one of these relationships. So if we know how to write the temporal predicates in these queries, we will know how to write any temporal predicate for any query.
Allen Relationship Queries
The value of reviewing all the Allen relationships in terms of queries against asserted version tables is that, as we already know, the Allen relationships are exhaustive. There are no positional relationships along a common timeline, among time periods and/or points in time, other than those ones. Thus, by showing how to write a query for each one of them, as well as for the groups of them identified in our taxonomy, we will have provided the basic material out of which any query against any assertion version table may be expressed.
In addition to the thirteen Allen relationships themselves, our taxonomy provides five additional relationships, each of which is a logical combination of two or more Allen relationships. And these combinations are not formed simply by stringing together Allen relationships with OR predicates. Although they are, necessarily, logically equivalent to the OR'd set of those relationships, they are often much simpler expressions, easier to understand and faster when executed.
In these sample queries, we will not include predicates for assertion time, and will pretend that our sample tables are uni-temporal versioned tables. This eliminates unnecessary detail from these examples. We will do this by using two version table views, shown below: V_Wellness_Program_Curr_Asr and V_Policy_Curr_Asr. The former is a view of all currently asserted Wellness Program versions. The latter is a view of all currently asserted Policy versions.
CREATE VIEW V_Wellness_Program_Curr_Asr AS
SELECT * FROM Wellness_Program_AV
WHERE asr_beg_dt <= Now()
AND asr_end_dt > Now()
CREATE VIEW V_ Policy _Curr_Asr AS
SELECT * FROM Policy_AV
WHERE asr_beg_dt <= Now()
AND asr_end_dt > Now()
In these example queries, as we said before, we will be selecting episodes, not versions. For the two tables used in this chapter, these are the views which provide episodes as queryable managed objects:
CREATE VIEW V_Wellness_Program_Epis AS
SELECT wp.wellpgm_oid, wp.epis_beg_dt, wp.eff_end_dt AS epis_end_dt, wp.welllpgm_nm, wp.wellpgm_nbr, wp.wellpgm_cat_cd
FROM V_Wellness_Program_Curr_Asr AS wp
WHERE wp.eff_end_dt =
(SELECT MAX(wpx.eff_end_dt)
FROM V_Wellness_Program_Curr_Asr AS wpx
WHERE wpx.wellpgm_oid = wp.wellpgm_oid
AND wpx.epis_beg_dt = wp.epis_beg_dt)
CREATE VIEW V_Policy_Epis AS
SELECT pol.policy_oid, pol.epis_beg_dt, pol.eff_end_dt AS epis_end_dt, pol.policy_type, pol.copay_amt, pol.client_oid, pol.policy_nbr
FROM V_Policy_Curr_Asr AS pol
WHERE pol.eff_end_dt =
(SELECT MAX(px.eff_end_dt)
FROM V_Policy_Curr_Asr px
WHERE px.policy_oid = pol.policy_oid
AND px.epis_beg_dt = pol.epis_beg_dt)
These episode views are the query-side work of defining an episode datatype. The AVF presents episodes as maintainable managed objects. These views present episodes as queryable managed objects.
This is a very important point. Both computer science research and IT practice have shown the importance of the concept of a string of one or more contiguous clock ticks with a known location in time. SQL does not directly support this concept; and so instead, we, and others, have to write code to exclude gaps and overlaps occurring in the timespan between a pair of dates or timestamps. A PERIOD datatype is the direct support needed for this concept. This datatype implements this concept at the correct level of abstraction.
By the same token, our own research and practice has shown the importance of the concept of an episode, a string of one or more contiguous and non-overlapping versions of the same object. Without that concept, and the concepts of objects and versions on which it depends, there is also no concept of temporal entity integrity and temporal referential integrity. Without that concept, collections of rows are defined, as needed, within each SQL statement. As we can see with both the standard and alternative temporal models, their SQL insert, update and delete statements do result in bi-temporal data that satisfies what we call TEI and TRI. Their SQL queries do find episodes, when they need them, past assertions when they need them, and so on. But the level of abstraction is wrong, for the same reason that getting the same results with a pair of dates that one would get with a PERIOD datatype is wrong.
So we now have two views which externalize, as queryable managed objects, the best data we currently have (i.e. our currently asserted data) about policy episodes and wellness program episodes. Now, using these two views, we will define another view that we will use to illustrate each of the Allen relationships. This is the view V_Allen_Example. This view will keep the examples as small and easy to understand as possible, eliminating all extraneous and repetitive detail while focusing on the Allen relationships themselves. Here is the V_Allen_Example view:
CREATE VIEW V_Allen_Example AS
SELECT wp.wellpgm_oid, pol.policy_oid,
wp.epis_beg_dt AS wp_epis_beg_dt,
wp.epis_end_dt AS wp_epis_end_dt,
pol.epis_beg_dt AS pol_epis_beg_dt,
pol.epis_end_dt AS pol_epis_end_dt
FROM V_Wellness_Program_Epis AS wp,
V_Policy_Epis AS pol
WHERE wp.wellpgm_nm = ‘Diabetes’
AND wp.epis_beg_dt >= ‘1/1/2009’
AND wp.epis_beg_dt <= ‘12/31/2009’
As we said previously, these queries are not intended to represent realistic scenarios. Their sole purpose is to demonstrate that all Allen relationships can be expressed as queries against asserted version tables. Note in particular that the two tables in this view are not correlated by a key, whereas they normally would be correlated with a join predicate. This is so we can see how the Allen relationships correlate the two tables using dates.
Time Period to Time Period Queries
Allen relationships may relate two time periods, or a time period to a point in time, or two points in time. We will represent time periods, using our closed-open notation, as follows:
Period 1: [eff_beg_dt1 – eff_end_dt1]. Referred to as P1.
Period 2: [eff_beg_dt2 – eff_end_dt2]. Referred to as P2.
Eff_beg_dt1 is earlier than eff_end_dt1, and eff_beg_dt2 is earlier than eff_end_dt2. This is true even for the limiting case of a time period that includes only a single clock tick.
P1 [starts] P2
This is a pair of relationships, one the inverse of the other. 1 In the non-superscripted relationship, the first time period is the shorter one. Figure 14.2 shows this relationship, and its place in our taxonomy. The two dashed lines in the illustration graphically represent P1 and P2, with P1 being the upper dashed line.
1The names of the Allen relationships are standard. They were provided by Allen in his original article, and continue to be used throughout the computer science literature.
B9780123750419000145/f14-02-9780123750419.jpg is missing
Figure 14.2
P1 [starts] P2.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 = eff_beg_dt2)
AND (eff_end_dt1 < eff_end_dt2)
It says that P1 and P2 begin at the same time, but that P1 is the first to end, and is therefore the shorter of the two time periods.
The inverse of this relationship is: P1 [starts−1] P2. In the superscripted relationship, the first time period is the longer one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 = eff_beg_dt2)
AND (eff_end_dt1 > eff_end_dt2)
It says that P1 and P2 begin at the same time, but that P1 is the last to end, and is therefore the longer of the two time periods.
Consider the following request for information: which policies began when the Diabetes Management Wellness Program for 2009 began, but ended while that program was still going on?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt = wp_eff_beg_dt
AND pol_epis_end_dt < wp_epis_end_dt
P1 [finishes] P2
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the shorter one. Figure 14.3 shows this relationship, and its place in our taxonomy. The two dashed lines in the illustration graphically represent P1 and P2, with P1 being the upper dashed line.
B9780123750419000145/f14-03-9780123750419.jpg is missing
Figure 14.3
P1 [finishes] P2.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 > eff_beg_dt2)
AND (eff_end_dt1 = eff_end_dt2)
It says that P1 and P2 end at the same time, but that P1 is the last to begin, and is therefore the shorter of the two time periods.
The inverse of this relationship is: P1 [finishes−1] P2. In the superscripted relationship, the first time period is the longer one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 < eff_beg_dt2)
AND (eff_end_dt1 = eff_end_dt2)
It says that P1 and P2 end at the same time, but that P1 is the first to begin, and is therefore the longer of the two time periods.
Consider the following request for information: which policies began prior to the Diabetes Management Wellness Program for 2009, and ended when that program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt > wp_eff_beg_dt
AND pol_epis_end_dt = wp_epis_end_dt
P1 [aligns] P2
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [starts], [starts−1], [finishes] and [finishes−1] relationships.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
((eff_beg_dt1 = eff_beg_dt2) AND (eff_end_dt1 < eff_end_dt2))
OR ((eff_beg_dt1 > eff_beg_dt2) AND (eff_end_dt1 = eff_end_dt2))
AND NOT((eff_beg_dt1 = eff_beg_dt2) AND (eff_end_dt1 = eff_end_dt2))
B9780123750419000145/f14-04-9780123750419.jpg is missing
Figure 14.4.
P1 [aligns] P2.
It says that P1 and P2 either start or end at the same time, but do not both start and end at the same time.
This relationship has no inverse.
Consider the following request for information: which policies either began when the Diabetes Management Wellness Program for 2009 began, or ended when that program ended, but not both?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE ((pol_eff_beg_dt = wp_eff_beg_dt
AND pol_epis_end_dt < wp_epis_end_dt)
OR (pol_eff_beg_dt > wp_eff_beg_dt
AND pol_epis_end_dt = wp_epis_end_dt))
AND NOT(pol_eff_beg_dt = wp_eff_beg_dt
AND pol_epis_end_dt = wp_epis_end_dt)
P1 [during] P2
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the shorter one.
B9780123750419000145/f14-05-9780123750419.jpg is missing
Figure 14.5.
P1 [during] P2.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 > eff_beg_dt2)
AND (eff_end_dt1 < eff_end_dt2)
It says that P1 starts after P2 and ends before P2.
The inverse of this relationship is: P1 [during−1] P2. In the superscripted relationship, the first time period is the longer one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 < eff_beg_dt2)
AND (eff_end_dt1 > eff_end_dt2)
It says that P1 starts before P2 and ends after P2.
Consider the following request for information: which policies began after the Diabetes Management Wellness Program for 2009 began, and ended before that program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt > wp_eff_beg_dt
AND pol_epis_end_dt < wp_epis_end_dt
P1 [occupies] P2
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [starts], [starts−1], [finishes], [finishes−1], [during] and [during−1] relationships. In other words, it combines the [during] relationships with the [aligns] relationships. These are all the relationships in which one time period includes all the clock ticks that are in the other time period, but also includes at least one additional clock tick.
In the non-superscripted relationship, the first time period is the shorter one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
((eff_beg_dt1 >= eff_beg_dt2) AND (eff_end_dt1 <= eff_end_dt2))
AND NOT((eff_beg_dt1 = eff_beg_dt2) AND (eff_end_dt1 = eff_end_dt2))
It says that P1 doesn't start before P2, doesn't end after P2, but doesn't match P2. The idea behind it is that every clock tick that is in P1 is also in P2, but that there is at least one clock tick in P2 that is not also in P1.
The inverse of this relationship is: P1 [occupies−1] P2. In the superscripted relationship, the second time period is the shorter one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
((eff_beg_dt1 <= eff_beg_dt2) AND (eff_end_dt1 >= eff_end_dt2))
AND NOT((eff_beg_dt1 = eff_beg_dt2) AND (eff_end_dt1 = eff_end_dt2))
B9780123750419000145/f14-06-9780123750419.jpg is missing
Figure 14.6.
P1 [occupies] P2.
It says that P1 doesn't start after P2, doesn't end before P2, and doesn't match P2. The idea behind it is that there is no clock tick in P2 which is not also in P1, but that there is at least one clock tick in P1 which is not also in P2.
Throughout the book, whenever P1 [occupies−1] P2, we will say that P1is occupied by P2.
Consider the following request for information: which policies began on or after the Diabetes Management Wellness Program for 2009 began, and ended on or before that program ended, but did not both start and end at the same times as that program started and ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt >= wp_eff_beg_dt
AND pol_epis_end_dt <= wp_epis_end_dt
AND NOT (pol_eff_beg_dt = wp_eff_beg_dt
AND pol_epis_end_dt = wp_epis_end_dt)
P1 [equals] P2
This is a single relationship, and has no inverse.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 = eff_beg_dt2)
AND (eff_end_dt1 = eff_end_dt2)
It says that P1 and P2 both start and end at the same time.
Consider the following request for information: which policies began when the Diabetes Management Wellness Program for 2009 began, and ended when that program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt = wp_eff_beg_dt
AND pol_epis_end_dt = wp_epis_end_dt
B9780123750419000145/f14-07-9780123750419.jpg is missing
Figure 14.7.
P1 [equals] P2.
P1 [fills] P2
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [starts], [starts−1], [finishes], [finishes−1], [during], [during−1] and [equals] relationships. In other words, it combines the [equals] relationship with the [occupies] relationships.
In the non-superscripted relationship, the first time period is either the same duration or the shorter one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 >= eff_beg_dt2)
AND (eff_end_dt1 <= eff_end_dt2)
It says that P1 doesn't start before P2 and doesn't end after P2. The idea behind it is that it includes every relationship in which P2 has every clock tick that P1 has.
The inverse of this relationship is: P1 [fills−1] P2. In the superscripted relationship, the first time period is either the same duration or the longer one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 <= eff_beg_dt2)
AND (eff_end_dt1 >= eff_end_dt2)
B9780123750419000145/f14-08-9780123750419.jpg is missing
Figure 14.8.
P1 [fills] P2.
It says that P1 doesn't start after P2 and doesn't end before P2. The idea behind it is that it includes every relationship in which every clock tick in P2 is also in P1. Throughout the book, whenever P1 [fills−1] P2, we will say that P1is filled by P2.
Note that in the case where both begin dates are identical, and both end dates are identical, P1 both fills and is filled by P2.
This is a particularly useful group of Allen relationships because a parent and child in a temporal relationship satisfy temporal referential integrity just in case the child's time period [fills] the parent's time period.
Consider the following request for information: which policies began on or after the Diabetes Management Wellness Program for 2009 began, and also ended on or before that program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt <= wp_eff_beg_dt
AND pol_epis_end_dt >= wp_epis_end_dt
P1 [overlaps] P2
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the earlier one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 < eff_beg_dt2)
AND (eff_end_dt1 > eff_beg_dt2)
AND (eff_end_dt1 < eff_end_dt2)
It says that P1 starts before P2 starts and ends after P2 starts but before P2 ends.
B9780123750419000145/f14-09-9780123750419.jpg is missing
Figure 14.9.
P1 [overlaps] P2.
The inverse of this relationship is: P2 [overlaps−1] P1. In the superscripted relationship, the first time period is the later one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 > eff_beg_dt2)
AND (eff_beg_dt1 < eff_end_dt2)
AND (eff_end_dt1 > eff_end_dt2)
It says that P1 starts after P2 starts and before P2 ends, and ends after P2 ends.
Consider the following request for information: which policies began before the Diabetes Management Wellness Program for 2009, and ended while that program was still going on?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt < wp_eff_beg_dt
AND pol_epis_end_dt > wp_eff_beg_dt
AND pol_epis_end_dt < wp_epis_end_dt
P1 [intersects] P2
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [starts], [starts−1], [finishes], [finishes−1], [during], [during−1], [equals], [overlaps] and [overlaps−1] relationships. In other words, it combines the [overlaps] relationships with the [fills] relationships.
In the non-superscripted relationship, the first time period is the earlier one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 <= eff_beg_dt2)
AND (eff_end_dt1 > eff_beg_dt2)
It says that P1 starts no later than P2 starts, and ends after P2 starts. The idea behind it is that it includes every relationship in which P1 and P2 have at least one clock tick in common and in which P1 is the earlier time period.
The limiting case is that in which P1 ends at the same time P2 starts. So let P1 be [4/15/2010 – 5/13/2010] and let P2 be [5/12/2010 – 9/18/2010]. The clock tick they share is 5/12/2010.
The inverse of this relationship is: P1 [intersects−1] P2. The first time period in this non-superscripted relationship is the later one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 >= eff_beg_dt2)
AND (eff_beg_dt1 < eff_end_dt2)
B9780123750419000145/f14-10-9780123750419.jpg is missing
Figure 14.10.
P1 [intersects] P2.
It says that P2 starts no later than P1 starts, and ends after P1 starts. The idea behind it is that it includes every relationship in which P1 and P2 have at least one clock tick in common and in which P1 is the earlier time period.
All pairs of time periods that share at least one clock tick satisfy one or the other of these two predicates. So the predicate that expresses the truth condition for all time periods that share at least one clock tick is:
((eff_beg_dt1 < eff_end_dt2)
AND (eff_end_dt1 > eff_beg_dt2))
It says that either one of the clock ticks in P1 is also in P2 or that one of the clock ticks in P2 is also in P1. The idea behind it is that it covers all the cases where two time periods have at least one clock tick in common, regardless of which is the later time period.
It is interesting to look at this relationship in terms of what falls outside its scope. For any two relationships that share at least one clock tick, neither ends before the other begins. Otherwise, they could not share a clock tick. Looking at [includes] in terms of what falls outside its scope, we can express it as follows:
NOT(eff_end_dt1 <= eff_beg_dt2) AND NOT(eff_beg_dt1 >= eff_end_dt2)
And for those who like as few NOTs as possible, a logical rule (one of the transformation rules known as the De Morgan's equivalences) gives us the following predicate:
NOT((eff_end_dt1 <= eff_beg_dt2) OR (eff_beg_dt1 >= eff_end_dt2))
In other words, if two things are both not true, then it isn't true that either of them is true! On such profundities are the rules of logic constructed.
Consider the following request for information: which policies share any clock tick with the Diabetes Management Wellness Program for 2009?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt < wp_epis_end_dt
AND pol_epis_end_dt > wp_eff_beg_dt
Notice how this SQL is much simpler than the OR'd collection of all of the conditions that make up the leaf nodes of its Allen relationships.
P1 [before] P2
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the earlier one.
B9780123750419000145/f14-11-9780123750419.jpg is missing
Figure 14.11.
P1 [before] P2.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_end_dt1 < eff_beg_dt2)
It says that after P1 ends, there is at least one clock tick before P2 begins. For example, consider the case where eff_end_dt1 is 5/13/2014 and eff_beg_dt2 is 5/14/2014. Because of the closed-open convention, the last clock tick in P1 is 5/12/2014, and so there is one clock tick gap between the two time periods, that clock tick being 5/13/2014.
The inverse of this relationship is: P1 [before−1] P2. In the superscripted relationship, the first time period is the later one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 > eff_end_dt2)
It says that before P1 begins, there is at least one clock tick after P2 ends. For example, consider the case where eff_beg_dt1 is 5/14/2014 and eff_end_dt2 is 5/13/2014. Because of the closed-open convention, the last clock tick in P2 is 5/12/2014, and so there is one clock tick gap between the two time periods, that clock tick being 5/13/2014.
Throughout this book, if it isn't important which time period comes first, we will simply say that the two time periods are non-contiguous.
This is a particularly useful pair of relationships because they distinguish episodes of the same object from one another. Two adjacent versions—versions of an object with no other version of the same object between them—belong to different episodes just in case the earlier one is [before] the later one. Of two adjacent episodes of the same object, one is [before] the other, and the other is [before−1] the former.
Consider the following request for information: which policies ended at least one date before the Diabetes Management Wellness Program for 2009 began?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_epis_end_dt < wp_eff_beg_dt
P1 [meets] P2
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the earlier one.
The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_end_dt1 = eff_beg_dt2)
B9780123750419000145/f14-12-9780123750419.jpg is missing
Figure 14.12.
P1 [meets] P2.
It says that after P1 ends, P2 begins on the very next clock tick. There is no clock tick gap between them. Say that both dates are 5/13/2004. This means that the last clock tick in P1 is 5/12/2004 and the first clock tick in P2 is 5/13/2004, and so there are no clock ticks between the two time periods.
The inverse of this relationship is: P2 [meets−1] P1. In the superscripted relationship, the first time period is the later one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 = eff_end_dt2)
It says that before P1 begins, P2 ends on the previous clock tick. There is no clock tick gap between them.
This is a particularly useful relationship because it defines a collection of versions of the same object that belong to the same episode. Every adjacent pair of versions of the same object that do not share any clock ticks, i.e. in which neither includes the other, and which also do not have a single clock tick between them, belong to the same episode. The earlier version of the pair meets the later one; the later version is met by the earlier one.
Throughout this book, if it isn't important which of two time periods that meet come first, we will simply say that the two time periods are contiguous.
Consider the following request for information: which policies ended immediately before the Diabetes Management Wellness Program for 2009 began?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_epis_end_dt = wp_eff_beg_dt
P1 [excludes] P2
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [before], [before−1], [meets] and [meets−1] relationships.
In the non-superscripted relationship, the first time period is the earlier one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_end_dt1 <= eff_beg_dt2)
It says that P2 starts either immediately after the end of P1, or later than that. The idea behind it is that it includes every relationship in which P1 and P2 have no clock ticks in common and in which P1 is the earlier time period.
The inverse of this relationship is: P1 [excludes−1] P2. The first time period in this non-superscripted relationship is the later one. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_beg_dt1 >= eff_end_dt2)
It says that P2 ends either immediately before the start of P1, or earlier than that. The idea behind it is that it includes every relationship in which P1 and P2 have no clock ticks in common and in which P1 is the later time period.
B9780123750419000145/f14-13-9780123750419.jpg is missing
Figure 14.13.
P1 [excludes] P2.
All pairs of time periods that share no clock ticks satisfy one or the other of these two predicates. So the predicate that designates all and only those time periods that share no clock ticks is:
(eff-end-dt1 <= eff-beg-dt2) OR (eff-beg-dt1 >= eff-end-dt2)
It says that either P2 starts after P1 ends or ends before P2 starts. The idea behind it is that regardless of which time period comes first, they share no clock ticks.
It should be the case that two time periods [exclude] one another if and only if they do not [intersect] one another. If so, then if we put a NOT in front of the predicate for the [intersects] relationship, we should get a predicate which expresses the [excludes] relationship. 2 Putting a NOT in front of the [intersects] relationship, we get:
NOT((eff_beg_dt1 < eff_end_dt2)
AND (eff_end_dt1 > eff_beg_dt2))
2Since, at the time we are writing this paragraph, we haven't done this, it is an excellent way of finding out if we have made any logical mistakes so far.
This is a statement of the form NOT(X AND Y). The first thing we will do is transform it, according to the De Morgan's rules, into (NOT-X OR NOT-Y). This gives us:
NOT(eff_beg_dt1 < eff_end_dt2)
OR NOT(eff_end_dt1 > eff_beg_dt2)
Next, we can replace NOT(eff_beg_dt1 < eff_end_dt2) with (eff_beg_dt1 >= eff_end_dt2), and NOT(eff_end_dt1 > eff_beg_dt2) with (eff_end_dt1 <= eff_beg_dt2). This gives us:
(eff_beg_dt1 >=eff_end_dt2) OR (eff_end_dt1 <= eff_beg_dt2)
Finally, by transposing the two predicates, we get:
(eff_end_dt1 <= eff_beg_dt2) OR (eff_beg_dt1 >= eff_end_dt2)
And this is indeed the predicate for the [excludes] relationship, demonstrating that [excludes] is indeed logically equivalent to NOT[intersects].
Consider the following request for information: which policies either ended before the Diabetes Management Wellness Program for 2009 began, or began after that program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE (pol_epis_end_dt <= wp_eff_beg_dt
OR pol_eff_beg_dt >= wp_epis_end_dt)
Point in Time to Period of Time Queries
A point in time is a period of time that includes only one clock tick. Thus, using the closed-open convention, a point in time, T1, is identical to the period of time [T1 – T2] where T2 is the next clock tick after T1. The only difference is in the notation. In the following discussions, we will use the simpler notation, T1, for the point in time.
In this section, we consider periods of time that are longer than a single clock tick. Periods of time that are one clock tick in length are points in time, and we consider Allen relationships between two points in time later.
Given that P1 is longer than a single clock tick, it may or may not share a clock tick with T1. If it does, then T1 [occupies] P1. Otherwise, either one is [before] the other, or else they [meet].
In Asserted Versioning databases, all temporal periods are delimited with the same point in time granularities. When comparing time periods to time periods, the logic in the AVF does not depend on the granularity of the clock ticks used in temporal parameters, as long as all of them are the same. The clock ticks could be months (as they are in the examples throughout this book), days, seconds or microseconds of any size. As we noted in Chapter 3, the AVF can carry out its temporal logic without caring about granularity specifically because of the closed-open convention.
However, when comparing a point in time to a period of time, we must be aware of the granularity of the clock tick, and must often either add a clock tick to a point or period in time, or subtract a clock tick from a point or period in time. Consequently, we need to specify the clock tick duration used in the specific implementation to correctly perform this arithmetic. We will use “fCTD”, standing for “clock tick duration”, as the name of a function that converts an integer into that integer number of clock ticks of the correct granularity. So, for example, in:
eff_end_dt – fCTD(1)
fCTD takes on the value of one clock tick. If the granularity is a month, as it is in most of the examples in this book, the result will be to subtract one month from the effective end date. If the granularity is a millisecond-level timestamp, it will subtract one millisecond from that date. The fCTD function determines the granularity for a specific Asserted Versioning database from the miscellaneous metadata table, shown as Figure 8.7 in Chapter 8.
Different DBMSs use different date formats for date literals. It is also dependent on the default language and the date format currently set. These formats are shown in Figure 14.14.
B9780123750419000145/f14-14-9780123750419.jpg is missing
Figure 14.14
Date Formats for Date Literals.
We used the USA format in parts of the book, so we will assume that the default date format in our sample DBMS is the same.
Different DBMSs use different syntax for date arithmetic. SQL Server would use something like this:
AND DATEADD(DAY, -1, pol.eff_end_dt) > ‘07/15/2010’
where DAY is the granularity (which can also be abbreviated as DD or D), while DB2 might use:
AND (pol.eff_end_dt - 1 DAY) > ‘07/15/2010’
with the reserved word DAY indicating the granularity. We will use the T-SQL format for our examples, and will assume our clock tick granularity is one month, to keep it in synch with the examples used in the book. However, in real-world databases, the granularity would more likely be a day, a second or a microsecond. This fCTD translation could be built into a reusable database function as part of the framework based on metadata.
T1 [starts] P1
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the point in time, i.e. the single clock-tick time period. Figure 14.15 shows this relationship, and its place in our taxonomy. The two dashed lines in the illustration graphically represent T1 and P1, with T1 being the upper dashed line.
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(T1 = eff_beg_dt)
It says that T1 starts at P1.
Consider the following request for information: which policies begin on the same date as the 2009 Diabetes Management Wellness Program?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt = wp_eff_beg_dt
B9780123750419000145/f14-15-9780123750419.jpg is missing
Figure 14.15.
T1 [starts] P1.
T1 [finishes] P1
This is a pair of relationships, one the inverse of the other. In the non-superscripted relationship, the first time period is the point in time, i.e. the single clock-tick time period. Figure 14.16 shows this relationship, and its place in our taxonomy. The two dashed lines in the illustration graphically represent T1 and P1, with T1 being the upper dashed line.
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(T1 = eff_end_dt – fCTD(1))
Since the effective end date of a time period is the next clock tick after the last clock tick in that time period, this predicate says that P1 ends on the clock tick that is T1.
Consider the following request for information: which policies began on the same date as the 2009 Diabetes Wellness Management Program ended?
B9780123750419000145/f14-16-9780123750419.jpg is missing
Figure 14.16.
T1 [finishes] P1.
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt = DATEADD(MONTH, -1, wp_epis_end_dt)
T1 [during] P1
This is the relationship in which a single clock tick occurs after the start of a period of time, and before that period of time ends. Figure 14.17 shows this relationship, and its place in our taxonomy. The two dashed lines in the illustration graphically represent T1 and P1, with T1 being the upper dashed line.
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(eff_beg_dt < T1) AND (eff_end_dt − fCTD(1) > T1)
It says that T1 occurs during P1 just in case P1 starts before T1 and ends after T1.
Consider the following request for information: which policies began before the 2009 Diabetes Wellness Management Program started, and ended after it started?
B9780123750419000145/f14-17-9780123750419.jpg is missing
Figure 14.17.
T1 [during] P1.
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt < wp_eff_beg_dt
AND DATEADD(MONTH, −1, pol_epis_end_dt) > wp_eff_beg_dt
T1 [occupies] P1
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which, when one of the time periods is a point in time, includes the [starts], [finishes], and [during] relationships. In other words, it combines the [during] relationships with the [aligns] relationships. These are all the relationships in which a time period (of more than one clock tick) includes a point in time.
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(eff_beg_dt <= T1) AND (eff_end_dt > T1)
It says that P1 occupies T1 just in case P1 starts on or before T1 and ends on or after T1.
B9780123750419000145/f14-18-9780123750419.jpg is missing
Figure 14.18.
T1 [occupies] P1.
Consider the following request for information: which policies began on or before the 2009 Diabetes Management Wellness Program started, and ended on or after it started?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE pol_eff_beg_dt <= wp_eff_beg_dt
AND pol_epis_end_dt > wp_eff_beg_dt)
T1 [before] P1
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(T1 + fCTD(1) < eff_beg_dt)
It says that P1 starts at least one clock tick after T1; similarly T occurs at least one clock tick before P1 starts.
The inverse of this relationship is: P1 [before−1] T1. In this superscripted relationship, the time period is later than the point in time. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_end_dt < T1)
B9780123750419000145/f14-19-9780123750419.jpg is missing
Figure 14.19.
T1 [before] P1.
It says that P1 ends at least one clock tick before T1.
It follows that to pick out those versions or episodes which are non-contiguous with a given point in time, the predicate is:
(T1 + fCTD(1) < eff_beg_dt) OR (eff_end_dt < T1)
Consider the following request for information: which policies have a temporal gap between when they began and when the 2009 Diabetes Management Wellness Program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE wp_epis_end_dt
< pol_eff_beg_dt
T1 [meets] P1
The predicate for this relationship, as it holds between a period of time expressed as a pair of dates using the closed-open convention, and a point in time, is:
(T1 + fCTD(1) = eff_beg_dt)
It says that P1 starts immediately after T1.
The inverse of this relationship is: P1 [meets−1] T1. In this superscripted relationship, the time period is earlier than the point in time. The predicate for this relationship, as it holds between two time periods expressed as pairs of dates using the closed-open convention, is:
(eff_end_dt = T1)
B9780123750419000145/f14-20-9780123750419.jpg is missing
Figure 14.20.
T1 [meets] P1.
It says that P1 ends immediately before T1.
It follows that to pick out those versions, or episodes which are contiguous with a given point in time, the predicate is:
(T1 + fCTD(1) = eff_beg_dt) OR (eff_end_dt = T1)
Consider the following request for information: which policies began at the same time the 2009 Diabetes Management Wellness Program ended?
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE wp_epis_end_dt =
pol_eff_beg_dt
P1 [excludes] T1
This not an Allen relationship. It is the node in our taxonomy of Allen relationships which includes the [before], [before−1], [meets] and [meets−1] relationships.
The predicate for this relationship is:
(T1 + fCTD(1)) <= eff_beg_dt) OR (eff_end_dt <= T1)
It says that P1 starts after T1 or ends before T1. Note that if a time period's effective end date is T1, that time period ended the day before T1.
Consider the following request for information: which policies ended anytime before the 2009 Diabetes Management Wellness Program began or started anytime after the 2009 Diabetes Management Wellness Program began? Note that this is not the same as a request for policies which ended [before] the 2009 Diabetes Management Wellness Program began.
B9780123750419000145/f14-21-9780123750419.jpg is missing
Figure 14.21.
P1 [excludes] T1.
The SQL written to fulfill this request is:
SELECT * FROM V_Allen_Example
WHERE (pol_epis_end_dt <= wp_eff_beg_dt
OR DATEADD(MONTH, +1, wp_eff_beg_dt) <= pol_eff_beg_dt)
Point in Time to Point in Time Queries
Another special set of Allen relationships consists of the relationships between two points in time, T1 and T2. There are only three such relationships. One point in time may precede another and be non-contiguous with it, or precede the other and be contiguous with it, or be the same as the other.
T1 [before] T2
The predicate for this relationship, as it holds between two points in time, expressed as points in time, is:
((T1 + fCTD(1)) < T2)
It says that T1 comes before T2, and that there is at least one clock tick between it and T2. Note that because of the requirement for this one clock tick gap, the Allen relationship [before] does not mean the same thing as “before” in ordinary language.
The inverse of this relationship is: T1 [before−1] T2. The predicate for this relationship, as it holds between two points in time, expressed as points in time, is:
((T1fCTD(1)) > T2)
It says that T1 comes after T2, and that there is at least one clock tick between it and T2.
T1 [meets] T2
The predicate for this relationship, as it holds between two points in time, expressed as points in time, is:
((T1 + fCTD(1)) = T2)
B9780123750419000145/f14-22-9780123750419.jpg is missing
Figure 14.22.
T1 [before] T2.
It says that T1 comes immediately before T2.
The inverse of this relationship is: T1 [meets−1] T2. The predicate for this relationship, as it holds between two points in time, expressed as points in time, is:
((T1fCTD(1)) = T2)
It says that T1 comes immediately after T2.
T1 [equals] T2
The predicate for this relationship, as it holds between two points in time, expressed as points in time, is:
(T1 = T2)
It says that T1 and T2 are equal if and only if they occur on the same clock tick.
B9780123750419000145/f14-23-9780123750419.jpg is missing
Figure 14.23.
T1 [meets] T2.
B9780123750419000145/f14-24-9780123750419.jpg is missing
Figure 14.24.
T1 [equals] T2.
A Claims Processing Example
With the Asserted Versioning queries developed and discussed in this book, we have generally chosen to sacrifice realism in the examples in order to guarantee completeness of coverage. For example, in Chapter 13 we developed and discussed SQL views of nine categories of bi-temporal data, eight of those categories being what we called pipeline datasets. And yet few real-world collections of bi-temporal data, we acknowledged, would correspond to precisely one of those nine categories of data (with the one exception of currently asserted current versions of data, the category which corresponds to the data in a conventional table). Completeness of coverage was guaranteed, however, because those nine categories are a mathematical partitioning of all possible combinations of past, present and future assertion and effective time data.
Thus far in Chapter 14, we have developed and discussed SQL predicates, and SQL statements illustrating their use, each corresponding to one of the Allen relationships or one of the nodes in our taxonomy of Allen relationships. We have reviewed all possible Allen relationships, and taxonomic groupings of them, between pairs of time periods, between a time period and a point in time, and between two points in time. Once again, completeness of coverage has been guaranteed because of the use of a mathematical partitioning of all possible types of queries. But once again, the examples have not been very realistic.
In this section, we move on from completeness to verisimilitude. Having used a simplified set of health insurance data throughout this book, we continue by developing a query about claims issued against policies held by clients.
Claims data has not been used, so far, and so we begin with the SQL definition of a simplified Adjudicated Claims table.
CREATE TABLE dbo.Adjud_Claim (
claim_rowidintidentity,
policy_oidintnull,
claim_amtmoneynull,
service_dtdatetimedefault getdate()null,
adjud_dtdatetimenull,
row_crt_dtdatetimedefault getdate()not null)
This Adjudicated Claims table is not an asserted version table. It is an event table, not a persistent object table, and each of its rows represent an event on which an insurance claim was adjudicated. As an event, each claims adjudication has no persistence. It happens, and then it's over.
In the Adjudicated Claims table, policy_oid is not a foreign key, because there is no table for which it is the primary key. The Policy table is an asserted version table, and its primary key is the combination of policy_oid with assertion begin date and effective begin date. Nor is policy_oid a temporal foreign key, because Asserted Versioning does not recognize and manage referential relationships between non-temporal tables and asserted version tables. For example, the AVF may temporally delete a policy after several claims have been adjudicated that reference that policy, and it may temporally delete those policies effective at some point in time prior to the adjudication of those claims. It is the responsibility of the application which manages the Adjudicated Claims table to make sure it is not adjudicating claims against terminated policies.
Returning to our query, for each adjudicated claim, it will show the client number and name, the policy number, type and copay amount, and the claim service date, amount, and adjudication date.
For the policy associated with the claim, this query picks out the version of the policy that was in effect on the service date. Clearly, we are not interested in any other version of the policy. In particular, we are not interested in the version of the policy that is in effect when the query is run, or in the version of the policy that was in effect on the adjudication date. Those versions may in fact be correct, but we can't count on it. We want to see the version that was in effect at the time the medical service was rendered.
But there is more to picking out the correct policy data than this. We need, not simply the correct version, but the appropriate assertion of that version. For it is possible that, between the service date and the adjudication date or after the adjudication date, we found an error in the data about the policy as it was on the service date.
Say that the service date is 9/24/2009 and the adjudication date is 12/07/2009, and that between those two dates, we discovered and corrected an error in the version of the policy that was in effect on 9/24/2009, and then again after the adjudication another correction was made to the policy for the effective period of the service. This means that we have three rows representing the same version of the same policy, both purporting to describe the policy as it was on 9/24/2009. Which one do we want?
We want the one that was used to adjudicate the claim, of course, that being the assertion that was current on the adjudication date, 12/07/2009. So we want policy data that was effective on the service date, and asserted as of the adjudication date whether it was right or wrong because we want to see the source of the Explanation of Benefits (EOB) as the customer sees it.
This query also returns the client number and name of the client that owns the policy. Like most persistent object data, of course, that name may have changed over time. In this sample query, we choose to use the client data that was currently asserted at the time that the row in the Adjudicated Claims table was physically created.
Finally, we include one selection criterion on the query. We select those adjudicated claims where the claim amount is greater than the client's copay amount. These, of course, are the claims for which a payment will be made by the insurance company to the service provider.
Here is the query we have described.
SELECT c.client_nbr, c.client_nm,
p.policy_nbr, p.policy_type, p.copay_amt,
cl.service_dt, cl.claim_amt, cl.adjud_dt
FROM Claim cl
INNER JOIN Policy_AV p
ON p.policy_oid = cl.policy_oid
AND p.eff_beg_dt <= cl.service_dt
AND p.eff_end_dt > cl.service_dt
AND p.asr_beg_dt <= cl.adjud_dt
AND p.asr_end_dt > cl.adjud_dt
INNER JOIN Client_AV c
ON c.client_oid = p.client_oid
AND c.eff_beg_dt <= cl.row_crt_dt
AND c.eff_end_dt > cl.row_crt_dt
AND c.asr_beg_dt <= cl.row_crt_dt
AND c.asr_end_dt > cl.row_crt_dt
WHERE cl.claim_amt > p.copay_amt
ORDER BY cl.adjud_dt, c.client_nbr, p.policy_nbr, p.eff_beg_dt;
To conclude this section, we show what this query might look like if the SQL language supported PERIOD datatypes, and also our taxonomy of Allen relationships. We suppose that the taxonomy node [fills−1] is represented by the reserved word INCLUDES. With a SQL language like this, the Asserted Versioning schema no longer has pairs of dates to represent its two time periods. Instead, it has the single columns asr_per and eff_per.
SELECT c.client_nbr, c.client_nm,
p.policy_nbr, p.policy_type, p.copay_amt,
cl.service_dt, cl.claim_amt, cl.adjud_dt
FROM Claim cl
INNER JOIN Policy_AV p
ON p.policy_oid = cl.policy_oid
AND p.eff_per INCLUDES cl.service_dt
AND p.asr_per INCLUDES cl.adjud_dt
INNER JOIN Client_AV c
ON c.client_oid = p.client_oid
AND c.eff_per INCLUDES cl.row_crt_dt
AND c.asr_per INCLUDES cl.row_crt_dt
WHERE cl.claim_amt > p.copay_amt
ORDER BY cl.adjud_dt, c.client_nbr, p.policy_nbr, p.eff_beg_dt;
In either form, what is striking about the query is its simplicity relative to the complexity of the bi-temporal semantics that underlies it. Unlike queries in the standard temporal model and, for that matter, uni-temporal queries in the alternative temporal model as well, this query does not assemble a collection of rows and then proceed to check for temporal gaps and temporal overlaps within sub-selected collections of those rows. Asserted Versioning enforces bi-temporal semantics once, as the data is being created and modified, rather than each time the data is queried.
In Other Words
With appropriate temporal extensions to the SQL language, the expression of all thirteen Allen relationships, and of this and other relationships which are combinations of those thirteen relationships, would be greatly simplified. The first thing that is needed to support predicates for these relationships is to provide a PERIOD datatype, as we discussed in Chapter 3. With that datatype available, SQL could express each of the relationships we have discussed with one binary predicate relating two time periods (not two pairs of dates).
For example, instead of having to request data associated with two time periods such that the first starts before the second and ends after the second starts but before the second ends, we could simply request data associated with two time periods such that the first [overlaps] the second.
Or, instead of having to request data associated with two time periods such that the first doesn't start after the second and doesn't end before the second, we could simply request data associated with two time periods such that the first [fills] the second.
It is clearly easier to think about what information one wants from the database at the higher level of abstraction provided by this new datatype and these new relationships, rather than at the level of abstraction in which begin and end dates have to be used, as they are in the original formulation of the example. And it is just as clearly easier to write the corresponding SQL.
But even with today's SQL which lacks these temporal extensions, Asserted Versioning manages assertion and effective time date pairs as user-defined PERIOD datatypes, and supports all the Allen relationships as well as the other relationships in our Allen relationship taxonomy. Asserted Versioning thus provides a migration path to the day when these extensions are supported in the SQL standard and in commercial DBMSs.
Glossary References
Glossary entries whose definitions form strong inter-dependencies are grouped together in the following list. The same glossary entries may be grouped together in different ways at the end of different chapters, each grouping reflecting the semantic perspective of each chapter. There will usually be several other, and often many other, glossary entries that are not included in the list, and we recommend that the Glossary be consulted whenever an unfamiliar term is encountered.
We note, in particular, that none of the nodes in the Asserted Versioning taxonomy of Allen relationships are included in this list. In general, we leave taxonomy nodes out of these lists since they are long enough without them.
Allen relationships
Asserted Versioning Framework (AVF)
episode
clock tick
closed-open
contiguous
granularity
effective begin date
effective end date
object
PERIOD datatype
point in time
time period
temporal entity integrity (TEI)
temporal referential integrity (TRI)
the alternative temporal model
the standard temporal model
version
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset