10. Temporal Transactions on Single Tables
The Temporal Insert Transaction214
Creating an Episode216
Lengthening an Episode Backwards217
Lengthening an Episode Forwards219
Merging Episodes220
The Temporal Update Transaction222
Restricted and Unrestricted Temporal Transactions226
The Temporal Delete Transaction226
Deleting One or More Episodes227
Shortening an Episode Forwards228
Shortening an Episode Backwards230
Splitting an Episode231
Completeness Checks233
An Allen Relationship Completeness Check233
A Temporal Extent Transformation Completeness Check237
Glossary References238
In the previous chapter, we looked at the “specs” of the three types of temporal transactions. In this chapter, we'll take those transactions out for a spin and see exactly how the AVF responds to each one. Its response has two parts. After performing the edit and validity checks described in the previous chapter, the AVF looks to see if applying a transaction would violate temporal entity integrity (TEI) or temporal referential integrity (TRI). If it would violate either one, the transaction is rejected.
Otherwise, the temporal transaction is translated into one or more physical transactions which are then submitted to the DBMS. If the DBMS finds that applying any of those physical transactions would violate an entity integrity or a referential integrity constraint, it will reject that transaction. In response, the AVF will stop processing the temporal transaction, undo any changes that might have been made up to that point, and pass an error message back to the calling program.
But if all goes well, the transaction will continue on, and will update the database. In doing so, it will begin by preserving the original state of the version or versions about to be changed, doing this by withdrawing them into past assertion time. There is no preservation work to do with temporal inserts, but there is with both temporal updates and temporal deletes. After the preservation step, the AVF will place the representation of an object into one or more clock ticks, update the representation of an object in one or more clock ticks, or remove the representation of an object from one or more clock ticks.
Temporal referential integrity (TRI) is the subject of the next chapter. In this chapter, we will focus on temporal entity integrity (TEI). TEI checks insure that, at any given moment of assertion time or during any given period of assertion time, no object may be represented in an effective time clock tick more than once.
TEI applies to both episodes and to versions within episodes. For episodes, it is the constraint that no two episodes of the same object, in the same period of assertion time, either are contiguous with one another or share even a single clock tick. Using the terminology from our Allen relationship taxonomy, it is the constraint that no two episodes of the same object, in the same period of assertion time, either [meet] or [intersect]. They share no clock ticks, and they all have at least one unoccupied clock tick between them. One is always [before] the other.
For versions within an episode, temporal entity integrity is the constraint that each effective-time adjacent pair of versions [meet] but do not [intersect]. They share no clock ticks, and have no unoccupied clock ticks between them.
That's the theory. Now let's put it to work.
The Temporal Insert Transaction
A temporal insert transaction specifies a representation of an object (Figure 10.1). In the syntax we are using, that representation is the part of the transaction enclosed in brackets. It includes the object identifier (oid), if it is known to the user. If an oid is not provided on the transaction, the AVF attempts to find or create one according to the rules described in the previous chapter. Finally, the transaction either accepts the default values for its temporal parameters, or overrides one or more of them with explicit values.
B9780123750419000108/f10-01-9780123750419.jpg is missing
Figure 10.1
The Temporal Insert Transaction: Temporal to Physical Mapping.
The end result, if successful, is that the transaction has an oid, an effective time period, and an assertion time period. The default effective time period for a temporal transaction is [Now() – 12/31/9999], but either effective date can be overridden. The default assertion time period is also [Now() – 12/31/9999]. In Chapter 12, we will see what happens if the assertion begin date default is overridden; but until then, we will assume that all transactions accept this default.
The temporal insert is the simplest of the three temporal transactions to implement. There are no existing versions to be withdrawn and then replaced and/or superceded. As long as not a single clock tick in the transaction's target timespan [intersects] the effective time period of some version of the same object that is already in the target table, the insert is valid. Otherwise, the transaction would violate TEI, and therefore is rejected by the AVF.
A valid insert is always carried out by creating one version. Sometimes the result is a new episode. Sometimes the result is to {lengthen an existing episode forwards}. 1 Sometimes, in being lengthened, an episode “bumps into” another episode and the two episodes are {merged}. When an insert creates a new episode, or {lengthens an episode forwards} (without bumping into the next episode), no other versions are affected. But otherwise, i.e. when {lengthening an episode backwards} or when {merging} two episodes, an insert does require some adjustment on the part of other versions.
1“{lengthen forwards}” is a two-word temporal extent state transformation name that, for the sake of readability, often needs a pronoun or a noun in the middle. For example, “{lengthen it forwards}” or “{lengthen an episode forwards}”. In any of these alternative forms, however, it is still the {lengthen forwards} transformation that is being referred to. The same is true for the names “{lengthen backwards}”, “{shorten forwards}” and “{shorten backwards}”.
Creating an Episode
Figure 10.2 depicts the history of policy P861 along a fragment of the calendar timeline, the fragment extending from January 2010 through January 2014. Let's recall that our examples all use, unless otherwise indicated, a clock that ticks once a month. And so, using our page-width-preserving notation, “Jan10” stands for January 1st, 2010, “May12” for May 1st, 2012, and so on. In the text, we will write, more concisely, “January 2010” and “May 2012”, not bothering to indicate that the clock always starts the tick on the first moment of the first day of each month and lasts through the last moment of the last day of that month.
B9780123750419000108/f10-02-9780123750419.jpg is missing
Figure 10.2
Creating an Episode: Before the Transaction.
We emphasize here a point that we originally made in Chapter 3. A clock tick is a logical concept, not a physical one. It is the smallest unit of time that can intervene between two adjacent versions of the same object. Thus, if one version begins on the first of the month, then given the granularity for clock ticks used in the examples in this book, the next one cannot begin until the first of the next month.
A clock tick gap, in physical time, is whatever the duration of a clock tick happens to be. But the duration of a clock tick, in physical time, is not the issue. As far as recorded data is concerned, there is no duration. There are either clock ticks that happen between two rows of interest to us, or clock ticks that don't.
Unless otherwise indicated, these diagrams show the history of our policy as we currently believe it to be. In other words, it depicts the history of our policy in current assertion time.
Here is a temporal insert transaction, which takes place on August 2011.
INSERT INTO Policy [P861, C882, PPO, $30] Jan 2011, Mar 2011
This is a retroactive transaction because it is attempting to insert a representation of the policy into an effective time period that is already in the past. This transaction is directing us to insert its data into January 2011 and February 2011. Another way to express this target time period in English, using this example, would be “Starting on January 2011 and continuing up to but not including March 2011 . . . . .”
Immediately prior to this transaction, the currently asserted life history of policy P861 is as shown in Figure 10.2. After the transaction is completed, that history will be the history of the policy as asserted up to (but not including) August 2011. The new currently asserted history of the policy will be as shown in Figure 10.3.
B9780123750419000108/f10-03-9780123750419.jpg is missing
Figure 10.3
Creating an Episode: After the Transaction.
Episode C, as we have labeled it, is a single-version episode. Of course all episodes, when initially created, are single-version episodes. Using the in-line notation introduced in Chapter 6, this new episode looks like this:
P[P861[Jan11-Mar11][Aug11-9999][Jan11][C882, PPO, $30][Aug11]]
This example shows our business correcting a mistake. The mistake was forgetting to record that policy P861 was in effect for those two months until eight months after the fact. What probably happened is that in August, the policy holder filed a claim against the policy. The claim was rejected, the policy holder complained, people in the company did some research, the customer service representative apologized, the policy was retroactively created and, finally, the claim was processed.
New episodes can be created proactively, before they go into effect, just as easily as they can be created retroactively, after they go into effect. But in the scenario shown here, that is not possible. The reason is that Episode B is an open episode; it remains in effect until further notice. Its version 4 has an effective end date of 12/31/9999. Therefore, any attempt to proactively create a new episode, i.e. to create an episode that began sometime after August 2011, would violate temporal entity integrity.
Lengthening an Episode Backwards
In the previous example, the mistake our company made was to fail to record that a policy was in effect until several months after the fact. Another kind of mistake is to get the effective begin date wrong. For example, Figure 10.3 shows the first episode of our policy becoming effective on February 2010. But let's suppose that the correct date was actually the month before that. How will we make this correction?
Because this correction will place data about an object into a clock tick where it previously was absent, it is carried out with a temporal insert transaction. Similarly, if we mistakenly place data about an object into a clock tick where it doesn't belong, we will need to use a temporal delete transaction to correct our mistake. So we should note that with temporal data, it is not just update transactions that can correct mistakes.
Immediately prior to this transaction, the currently asserted life history of policy P861 is as shown in Figure 10.3. It is still August 2011, and we now submit the following transaction to the AVF:
INSERT INTO Policy [P861, C882, PPO, $30] Jan 2010, Feb 2010
Immediately after this transaction is completed, that history will be the history of the policy as asserted from when the previous transaction was applied up to August 2011. The new currently asserted history of the policy will be as shown in Figure 10.4. The new version—version 6—looks like this:
P[P861[Jan10-Feb10][Aug11-9999][Jan10][C882, PPO, $30][Aug11]]
B9780123750419000108/f10-04-9780123750419.jpg is missing
Figure 10.4
Lengthening an Episode Backwards: After the Transaction.
Unlike our first insert transaction, this one does not create a new episode; it extends an existing episode backwards in time. But in doing so, it changes that episode's begin date. As we can see from the schema common to all asserted version tables, the episode begin date is repeated on every version in an episode. And by extending this episode backwards, this transaction changes that episode's begin date. So as part of the atomic isolated unit of work started by this transaction, the AVF must also change the episode begin date on versions 1 and 2, the other two versions in the new Episode A. This is done by withdrawing those two versions and replacing them with versions identical to them except that they have the correct episode begin date. Those two replacement versions are versions 7 and 8, and the versions they replace are shown as superscripts next to them. At the end of the transaction, versions 6, 7 and 8 make up the currently asserted Episode A, and all have an episode begin date of January 2010.
Lengthening an Episode Forwards
Another thing we can use a temporal insert for is to {extend an episode forwards} in time. This is, naturally enough, much the same process as {extending an episode backwards}. In both cases, the timespan of the transaction must [meet] the timespan of an episode already in the table. The two timespans cannot [intersect], and they cannot have a gap between them. 2 However, {extending an episode forwards} is a little less work for the AVF than {extending an episode backwards} because extending forwards leaves the episode begin date unchanged on the other versions in the episode.
2In Allen relationship terms, one cannot be [before] the other. However, since one clearly is before the other, as we understand the word “before”, Allen relationship terminology is, in this instance, somewhat unfortunate.
All of our temporal inserts, so far, have done retroactive work. So let's set up this next example as a proactive transaction. The main lesson to be learned is that the distinction between proactive and retroactive transactions is one we make, but not one that matters to the AVF. It is a matter of the relationship between when the transaction takes place, and what period of effective time it affects. As a relationship between a point in time and a period of time, the basic options are that the point in time can be earlier than the period of time, within the period of time, or later than the period of time. This gives us, against a current episode, proactive, current and retroactive temporal transactions.
To illustrate a proactive transaction, let's assume that it is now May 2010, and that at this point in time, our database looks as shown in Figure 10.5.
B9780123750419000108/f10-05-9780123750419.jpg is missing
Figure 10.5
Lengthening an Episode Forwards: Before the Transaction.
It is May 2010, and the following transaction is submitted to the AVF:
INSERT INTO Policy [P861, C882, HMO, $25] Oct 2010, Dec 2010
Immediately after this transaction is completed, the history shown in Figure 10.5 will no longer be currently asserted. Instead, it will be the history of the policy as asserted from when the previous transaction was applied up to May 2010. The new currently asserted history of the policy will be as shown in Figure 10.6. Version 9 looks like this:
P[P861[Oct10-Dec10][May10-9999][Jan10][C882, HMO, $25][May10]]
B9780123750419000108/f10-06-9780123750419.jpg is missing
Figure 10.6
Lengthening an Episode Forwards: After the Transaction.
Episode begin dates are not supplied on transactions. They are always determined by the AVF. In this case, the AVF sees that there is already a version of that same policy in the table whose effective end date [meets−1] the effective begin date on the transaction. Because this match means that the episode is being extended forwards, the AVF assigns version 9 the episode begin date on the version it is contiguous with—in this case, version 8.
So now, on May 2010, we are claiming that we know several things about policy P861's future. We know that it will remain in effect until December 2010, i.e. through November 30th, 2010. We know that from May 2010 to October 2010, it will have the properties ascribed to it by version 8. We also know that in October and November of that year, it will be an HMO policy with a $25 copay.
We say we know this about the future. But, of course, as with any statement about the future, we may be wrong. However, since anyone viewing this data about the future will understand this, we are misrepresenting nothing.
Merging Episodes
We have seen how temporal inserts can create new episodes and can extend existing episodes backwards and forwards. But when any but the latest episode of an object is extended forwards, there is an episode ahead of it to “bump into”. Similarly, when any but the earliest episode of an object is extended backwards, there is an episode behind it to bump into.
In either case, however, a successful temporal insert will {merge} the two adjacent episodes together. The resulting episode will contain all the versions in both of the original episodes, and also the one version that caused them to {merge}.
To illustrate a temporal transaction merging two episodes, let's go all the way back to Figure 10.2 and assume that it is now January 2012. Immediately after this next transaction is completed, the history shown in Figure 10.2 will no longer be currently asserted. Instead, it will be the history of the policy as asserted from when the previous transaction was applied up to January 2012. The new currently asserted history of the policy will be as shown in Figure 10.7.
B9780123750419000108/f10-07-9780123750419.jpg is missing
Figure 10.7
Merging Adjacent Episodes: After the Transaction.
It is now January 2012, and the following transaction is submitted to the AVF:
INSERT INTO Policy [P861, C882, POS, $15] Oct 2010, Apr 2011
Version 7 looks like this:
P[P861[Oct10-Apr11][Jan12-9999][Feb10][C882, POS, $15][Jan12]]
The AVF sees that this transaction will {merge} two episodes. It can tell that because there are already two versions of that same policy in the table such that the effective end date of the earlier one [meets−1] the effective begin date on the transaction, and the effective begin date of the later one [meets] the effective end date on the transaction. Because the result is a single episode, all versions in that episode must have the same episode begin date. Therefore, to complete the transaction, the AVF sets the episode begin date of version 7 to February 2010, and withdraws versions 3 and 4, replacing them with versions that are identical except that they remain in current assertion time and have an episode begin date of February 2010.
We have now discussed all the temporal extent transformations that are carried out in response to a temporal insert transaction. At the end of this chapter, we will review the taxonomy of temporal extent transformations shown in Figure 9.5 (and repeated as Figure 10.21) to be sure that we have demonstrated that each of them can be produced by one of the three temporal transactions.
B9780123750419000108/f10-21-9780123750419.jpg is missing
Figure 10.21
A Taxonomy of Asserted Versioning Temporal Extent Transformations.
In the meantime, let's turn to temporal update transactions. But before we do, let's note that update transactions do not bring about temporal extent transformations. A temporal extent transformation necessarily involves adding the representation of an object to one or more clock ticks, or removing the representation of an object from one or more clock ticks. Temporal updates do neither. They simply change business data on versions that [intersect] a designated target range.
The Temporal Update Transaction
A temporal update transaction specifies (i) an object, (ii) a value for one or more columns of business data, and (iii) a target effective timespan, which we sometimes also call a target range for the transaction. The transaction includes the object identifier (oid), if it is known to the user. If an oid is not provided on the transaction, the AVF attempts to find or create one according to the rules described in the previous chapter. Finally, the transaction either accepts the default values for its temporal parameters, or overrides one or more of them with explicit values.
Although a temporal update does not alter the temporal extent of an object, it is still the most complex of the three temporal transactions to implement. There are always existing versions that must be withdrawn. If parts of those versions do not [intersect] the transaction's target range, those parts must be replaced. Then the parts of versions or entire versions that do [intersect] the target range must be superceded with versions that contain the new data.
As long as even a single clock tick in the transaction's target range [intersects] the effective time period of some version of the specified object, the temporal update is valid because it means that there is data for the transaction to modify. A valid update is always carried out by creating one new version for every version found within the target range, as well as a new version for every part of a version found within the target range. These versions are the ones that supercede, in current assertion time, the versions that fall within the timespan of the transaction. A valid update will also create a new version for those parts of versions, if any, that do not [intersect] the target range. These new versions contain no new business data. They are simply replacements for those parts of withdrawn versions that were unaffected by the update.
A temporal update's target range may include part of an episode or version, an entire episode or version, multiple episodes or versions, or any combination thereof. But a temporal update never creates a new episode, and never adds to or subtracts from the total count of clock ticks occupied by its referenced object.
We will need only a single example to illustrate the most important variations of temporal updates. We begin with a sample database whose rows 1–6 represent the versions 3–8 shown in Figure 10.4. This is the sample database shown in Figure 10.9. Row 1 represents version 7, the currently asserted replacement for version 1. Row 2 represents version 8, the currently asserted replacement for version 2. Rows 3–6 represent versions 3–6.
B9780123750419000108/f10-09-9780123750419.jpg is missing
Figure 10.9
Updating a Policy: Before the Transaction.
We will show none of the past assertion history that led to this database state, but only the six versions that are currently asserted. But because this is a relatively complex transaction, we will illustrate its progress one physical transaction at a time.
The mapping shown in Figure 10.8 illustrates the steps the AVF will go through to complete the temporal update.
B9780123750419000108/f10-08-9780123750419.jpg is missing
Figure 10.8
The Temporal Update Transaction: Temporal to Physical Mapping.
We begin by withdrawing the affected versions. The transaction specifies the timespan [Jul 2010 – Jul 2011]. Part of version 8, and all of versions 5 and 3, [fill−1] this timespan. So the first step is to withdraw these three versions. Since no assertion begin date was explicitly specified on the transaction, that date defaults to Now(), January 2012. The result is shown in Figure 10.10. Using a convention described previously, we enclose in angle brackets the row numbers of all rows which are part of this atomic, isolated unit of work and, because these rows are now withdrawn, we show them shaded.
B9780123750419000108/f10-10-9780123750419.jpg is missing
Figure 10.10
Updating a Policy: Withdrawing the Versions in the Target Range.
Only part of row 2 (version 8) [intersects] the range of the transaction. Since row 2 has been withdrawn into past assertion time, the next thing we must do is to replace, in current assertion time, that part of the version that the transaction is not concerned with. To do this, the AVF creates a version whose effective time period extends from version 8's effective begin date up to the effective begin date of the transaction, July 2010. The result is row 7, shown in Figure 10.11.
B9780123750419000108/f10-11-9780123750419.jpg is missing
Figure 10.11
Updating a Policy: Replacing the Unaffected Part of Version 2.
The rest of version 8 does [fill−1] the range of the transaction, as do all of versions 5 and 3. The versions which take the place of these two versions are not replacements, because they do not contain identical business data. Instead, they are versions which supercede the original versions with the new business data. To supercede these versions, the AVF first creates a version whose effective time period extends from the transaction's effective begin date up to the effective end date of version 8. The result is row 8, shown in Figure 10.12.
B9780123750419000108/f10-12-9780123750419.jpg is missing
Figure 10.12
Updating a Policy: Superceding the Affected Versions.
The last step for the AVF is to insert rows 9 and 10. Row 9 supercedes row 3 (version 3 in Figure 10.4), and row 10 supercedes row 5 (version 5). The temporal update transaction is now complete. The atomic unit of work is over, and the DBMS can release its locks on the rows involved in this transaction. These rows are no longer isolated, but are now part of the database.
Restricted and Unrestricted Temporal Transactions
The temporal update transactions discussed in this book are restricted temporal updates. By that we mean that these transactions designate a specific object, a span of effective time, and a value for one or more columns of business data, and then change all representations of that object, in all clock ticks within that timespan, to those new values. But limited to only restricted update transactions, Asserted Versioning could not, for example, change the copay amounts on all policies within a target timespan provided that the original amounts are less than a certain value. Instead, the AVF could only change all copay amounts within that timespan, for a single object, to that new value.
Obviously, a series of carefully designed restricted temporal updates could produce any desired result, and do so across any set of objects. But just as obviously, it would be a tedious process. And because of the careful analysis required, it would also be an error-prone process.
As we go to press, these limitations on temporal update transactions have been removed. Release 1 of our Asserted Versioning Framework now supports unrestricted temporal update transactions, ones which will update multiple objects within a target timespan, and will do so based on WHERE clause qualifying criteria. The AVF also now supports unrestricted temporal deletes as well.
In addition, instead of requiring the user to write transactions in a proprietary format required by an Application Programming Interface (API) we were developing, the AVF now accepts temporal insert, update and delete transactions written as native SQL. This is done by means of Instead of Triggers, as described in the section Ongoing Research and Development, in Chapter 16.
Our new support for unrestricted temporal transactions, written as native SQL statements, can be found on our website AssertedVersioning.com.
The Temporal Delete Transaction
A temporal delete transaction specifies an object and a target range for the transaction (Figure 10.13). It includes the object identifier, if it is known to the user. If an oid is not provided on the transaction, the AVF attempts to find one according to the rules described in the previous chapter. Finally, the transaction either accepts the default values for its temporal parameters, or overrides one or more of them with explicit values.
B9780123750419000108/f10-13-9780123750419.jpg is missing
Figure 10.13
The Temporal Delete Transaction: Temporal to Physical Mapping.
A temporal delete is the inverse of a temporal insert. A temporal insert always increases the total number of clock ticks occupied by an object. A temporal delete always decreases the total number of those clock ticks.
As long as even a single clock tick in the transaction's target timespan [intersects] the effective time period of some version of the same object, the delete is valid because it means that there is data in one or more clock ticks for the delete to move into past assertion time.
A temporal delete's target range may include part of an episode or version, an entire episode or version, multiple episodes or versions, or any combination thereof. But a temporal delete never creates a new episode or version in clock ticks that were previously unoccupied, just as a temporal insert never removes one from clock ticks that were previously occupied.
Deleting One or More Episodes
We will begin with the set of three episodes shown in Figure 10.14. These are the current episodes A, B and C after being updated as shown in Figure 10.12. We have also reset the version numbers so they correspond to the row numbers in Figure 10.12.
B9780123750419000108/f10-14-9780123750419.jpg is missing
Figure 10.14
Deleting an Episode: Before the Transaction.
To completely remove an episode from current assertion time, we do not need to provide the exact begin and end dates of the episode, but simply need to include its effective time period in the transaction's target timespan. If that target timespan includes that of the episode, the result is to remove the entire episode, i.e. to {erase} that episode from current assertion time.
It is now March 2012, and either of the following two transactions is submitted to the AVF:
DELETE FROM Policy [P861] Jan 2010, Nov 2010
or
DELETE FROM Policy [P861] Jan 2010, Dec 2010
These two temporal delete transactions have the same result. They both {erase} Episode A, the episode consisting of versions 6, 1, 7 and 8. The author of the transaction will not be confused by this fact provided she remembers that a delete transaction simply stops asserting the presence of an object anywhere in the effective timespan indicated on the transaction. Both timespans shown here contain exactly the same occupied clock ticks.
Withdrawing these versions is the first of the three physical transaction steps shown in Figure 10.15. As for the other two steps, neither of them is needed to complete this temporal transaction. The reason is that since an entire episode is being {erased}, and the object is represented nowhere else in the target timespan, no other episodes are affected. We can think of the empty clock tick or clock ticks that exist on both ends of an episode as insulating other episodes from whatever happens to just that one episode.
B9780123750419000108/f10-15-9780123750419.jpg is missing
Figure 10.15
Deleting an Episode.
Shortening an Episode Forwards
We still currently assert episodes C and B in Figure 10.14. It is now May 2012, and the following transaction is submitted to the AVF:
DELETE FROM Policy [P861] Jan 2011, May 2011
This transaction will {erase} Episode C, and {shorten Episode B forwards} by one month.
Because the delete transaction {shortens Episode B forwards}, it alters the episode begin date. Specifically, it changes that begin date from April 2011 to May 2011. This transaction will require all three of the physical transaction steps shown in Figure 10.13.
The first physical transaction step withdraws versions 9 and 10. The result is shown in Figure 10.16. These versions have been withdrawn, as all versions are, by overwriting their assertion end dates. The overwrites which withdraw rows into past assertion time do not lose information, however, as overwrites of business data do. This is because we always know what the assertion end date was before the row was withdrawn. In all cases, it was 12/31/9999. This is guaranteed because (i) all versions are created with an assertion end date of 12/31/9999, and (ii) the AVF will never alter an assertion end date that is not 12/31/9999.
B9780123750419000108/f10-16-9780123750419.jpg is missing
Figure 10.16
Shortening an Episode Forwards: After Step 1.
In comparing the transaction's time period to that of the episode, we see that it completely includes version 10 but only [overlaps] version 9. So, having withdrawn version 9, we must now replace it with a version identical to it except that its effective time period begins on May 2011. But because version 9 is the first version of Episode B, it changes the episode begin date of the episode from April 2011 to May 2011. This, in turn, affects version 4, which is the second version in that episode. Consequently, we must withdraw version 4, and replace it with a version that is identical to it except for having the new episode begin date. The result of all this work is shown in Figure 10.17.
B9780123750419000108/f10-17-9780123750419.jpg is missing
Figure 10.17
Shortening an Episode Forwards: After Step 2.
Episode C has been {erased}, completely withdrawn into past assertion time. Episode B has been {shortened forwards} by one month.
The first delete transaction we considered covered an entire episode, {removing} that episode by withdrawing all its versions into past assertion time. This delete transaction, however, left part of a target episode in current assertion time. It withdrew part but not all of that episode, bringing about the temporal extent transformation in which an episode is {shortened forwards}.
In this way, a temporal delete is different from a non-temporal delete. Non-temporal deletes remove the one and only row representing an object from the database. Temporal deletes remove some but not necessarily all of the possibly multiple rows representing an object, and may also remove part but not necessarily all of any one (or two) of those rows. And, of course, temporal deletes do not physically remove any data from the database. They just withdraw assertions and end the effective time of versions, so that at any point in time, what used to be the case can be recreated exactly as it was then.
Shortening an Episode Backwards
A temporal delete can also {shorten an episode backwards} in time. This happens when the transaction's target range [overlaps] later clock ticks in the episode (and perhaps additional clock ticks as well) while one or more earlier clock ticks are not [overlapped].
{Shortening an episode backwards} is easier than {shortening it forwards} because it doesn't alter the episode's begin date. Since the episode's begin date remains the same, the only versions in the episode that are affected by the transaction are those which [overlap] the transaction's target range. If we're really fortunate, the target range will line up on version boundaries. An example would be a temporal delete whose target range is [Jul 2011 – 12/31/9999] against the episode still asserted in Figure 10.17. In this case, the timespan on this transaction [equals] the effective time of version 12.
When a temporal delete's timespan lines up on a version boundary within a target episode, then all that has to be done is to withdraw the affected versions. Doing so, in this case, leaves an episode whose effective time extends from May 2011 to July 2011. So the effective end date, July 2011, of this previous version, row 11, would designate the end of the episode.
Splitting an Episode
{Splitting} an episode is a little more interesting than either {shortening an episode backwards} or {shortening an episode forwards}. The reason is that, from the point of view of the earlier of the two resulting episodes, {splitting} is {shortening an episode backwards}, while from the point of view of the later of the two resulting episodes, it is {shortening an episode forwards}. From the point of view of the “internals” of AVF processing, of course, it is simply another case of removing the representation of an object from a series of clock ticks, the case in which those clock ticks are contained within the clock ticks of a single episode.
Let's begin with the life history of policy P861 as represented in the table in Figure 10.15 and as graphically illustrated in Figure 10.14. In that table, versions (row numbers) 9 and 4 constitute a currently asserted episode, one which extends from April 2011 to 12/31/9999.
It is now February 2012. Note that this is one month before the {shorten forwards} transaction, described in the previous section, is processed. That's why we're going back to Figure 10.15, rather than to Figure 10.16. The following transaction is submitted to the AVF:
DELETE FROM Policy [P861] May 2011, Dec 2012
Policy P861 exists, in current assertion time, in every clock tick from May 2011 to December 2012. As we can see from version 9, it also exists for exactly one clock tick prior to that timespan. And as we can see from version 4, it exists past December 2012, into the indefinite future.
The first physical transaction step in this deletion is to withdraw versions 9 and 4 since each of them has at least one clock tick included in the timespan specified by the temporal delete. The result is shown in Figure 10.18.
B9780123750419000108/f10-18-9780123750419.jpg is missing
Figure 10.18
Splitting an Episode: After Step 1.
Having {erased} the entire episode, the next step is to replace those parts of those versions which lie outside the scope of the transaction. For version 9, [Apr 2011 – May 2011] is the single clock tick that must be replaced. For version 4, [Dec 2012 – 12/31/9999] is the effective timespan that must be replaced. The result is shown in Figure 10.19.
B9780123750419000108/f10-19-9780123750419.jpg is missing
Figure 10.19
Splitting an Episode: After Steps 2 and 3.
The second physical transaction step in carrying out a temporal delete is to assert the replacement versions which delimit the time period of the deletion. This is done with versions 12 and 13. Version 12 replaces the one clock tick from version 9 that was not included in the range of the delete. Version 13 replaces the clock ticks from December 2012 to 12/31/9999 from version 4 that were not included in the range of the delete.
The third physical transaction step resets any versions that need their episode begin dates reset. That is version 13. Version 4, which it replaces, belongs to an episode which began on July 2011. That episode has been {shortened forwards} by the transaction so that it now begins on December 2012, the effective begin date of what is now its only version.
Completeness Checks
We have now used all three temporal transactions, in a variety of situations. There are several ways to categorize the situations which temporal transactions might encounter, but we concluded, a couple of chapters ago, that we could not provide an example for all of them. Nonetheless, we would like some assurance that any semantically valid request to transform one or more asserted version tables from one state to another state can be made with temporal transactions and can be carried out with the physical transactions that the AVF maps them into.
We know of two ways to do this. One is with the Allen relationships. The other is with our taxonomy of temporal extent state transformations. The relationship of these two ways of demonstrating completeness is this. While we will use the Allen relationships to compare temporal transactions to their target episodes, we will use the temporal extent state transformations to compare before and after states of a target database.
An Allen Relationship Completeness Check
First of all, it is well established that the Allen relationships are a mutually exclusive and jointly exhaustive set of all the possible relationships between two time periods along a common timeline that are based on the temporal precedence and succession of one to the other (Figure 10.20). We ourselves derived precisely those Allen relationships as the leaf nodes in a taxonomy of our own invention. Since taxonomies are tools for demonstrating mutual exclusion and joint coverage of an original root node, this is further proof, if any were needed, of the validity of the Allen relationships.
B9780123750419000108/f10-20-9780123750419.jpg is missing
Figure 10.20
The Asserted Versioning Allen Relationship Taxonomy.
In the case of temporal transactions, one of those two Allen relationship time periods is the effective time period specified on the transaction. The other time period is the effective time period of each episode and version to which those transactions may apply.
We should also remind ourselves that when we compare any two time periods in effective time, we are assuming that they exist in shared assertion time. When one of those time periods is on a transaction, that assertion time cannot begin in the past, and usually begins Now(); and the assertion time specified on the transaction always extends to 12/31/9999.
[Before], [before−1]. When a temporal transaction's effective time is non-contiguous with that of any episodes of the same object already in the target table, a temporal insert will {create} a new episode of the object. In Allen relationship terms, this means that, for any episode of the same object already in the target table, the effective time period specified on a temporal insert is either [before] or [before−1] that episode. Another way of making the same point is to say that the time period on the transaction is non-contiguous with the time period of any episode of the same object.
If the effective time period on a temporal update or delete transaction is either [before] or [before−1] the effective time period of every episode of the same object already in the target table, then the temporal transaction is invalid. It is equivalent to a conventional transaction trying to update or delete a row that isn't there.
[Meets], [meets−1]. When a temporal transaction's effective time [meets] or [meets−1] that of an episode of the same object already in the target table, a temporal insert will result in one or the other of the {lengthen} transformations, depending on whether the transaction's timespan is later than or earlier than that of the episode. Also, if a temporal insert transaction's effective time both [meets] one episode and [meets−1] an adjacent episode, the result will be a {merge} transformation.
The [before], [before−1], [meets] and [meets−1] relationships are subtypes, in our taxonomy, of the [excludes] relationship. And we can now see why this is an important group of relationships to define. Temporal insert transactions are valid only if they have an [excludes] relationship with every other episode of the same object already in the target table. And by the same token, temporal update and temporal delete transactions are valid only if there is at least one episode of the same object already in the target table with which they do not have an [excludes] relationship. So now that we are through with the [excludes] branch of the Allen taxonomy, we have exhausted all the Allen relationship possibilities for temporal insert transactions.
We will discuss how temporal delete transactions work with the remaining Allen relationships. We will not explicitly discuss temporal updates because temporal updates are semantically equivalent to temporal deletes followed by the insertion of updated versions which supercede those versions wholly or partially withdrawn. And so there are no Allen relationships possible for temporal updates that are not also possible for temporal deletes.
[Starts]. If a temporal delete transaction's effective time begins on the same clock tick as that of an episode, but ends earlier than the episode ends, it will withdraw all versions wholly or partially included within its timespan. If one version is partially within the timespan, the temporal delete will replace the part of that withdrawn version not within its timespan. In either case, the result is a {shorten backwards} transformation on that episode.
[Starts−1]. If a temporal delete transaction's effective time begins on the same clock tick as that of an episode, but ends after the episode ends, the transaction will {erase} the episode; and, in addition, it will withdraw all other versions, for the same object, that are wholly or partially included within its timespan.
Those other versions will exist within one or more later episodes. On any of those episodes wholly included within the transaction's timespan, there will be an {erase} transformation on them, as well. The last episode within the transaction's timespan may be wholly or partially included within that timespan. If it is wholly contained, there will be an {erase} transformation on it. Otherwise, there will be a {shorten forwards} transformation. If the end of the transaction's timespan does not fall on a version effective time boundary, then the temporal delete will replace the part of that withdrawn version that is not within its timespan.
[Finishes]. If a temporal delete transaction's effective time ends on the same clock tick as that of an episode, but begins after that episode begins, it will withdraw all versions wholly or partially included within its timespan. If one version is partially within the timespan, the temporal delete will replace the part of that withdrawn version not within its timespan. In either case, the result is a {shorten forwards} transformation on that episode.
[Finishes−1]. If a temporal delete transaction's effective time ends on the same clock tick as that of an episode, but begins before that episode begins, it will {erase} the episode; and, in addition, it will withdraw all other versions, for the same object, that are wholly or partially included within its timespan.
Those other versions will exist within one or more earlier episodes. On any of those episodes wholly included within the transaction's timespan, there will be an {erase} transformation on them, as well. The earliest episode within the transaction's timespan may be wholly or partially included within that timespan. If it is wholly contained, there will be an {erase} transformation on it. Otherwise, there will be a {shorten backwards} transformation. If the start of the transaction's timespan does not fall on a version effective time boundary, then the temporal delete will replace the part of that withdrawn version that is not within its timespan.
[During]. If a temporal delete transaction's effective time begins after that of an episode, and ends before that episode ends, then the transaction will withdraw all versions wholly or partially included within its timespan. At most two versions can be partially included in that timespan, those being the ones at the begin and/or end of the timespan. This delete transaction carries out a {split} transformation on the episode in question.
[During−1]. If a temporal delete transaction's effective time begins before that of an episode, and ends after that episode ends, then the transaction will {erase} the one or more episodes wholly included within its timespan. In addition, as well as any number of additional episodes wholly included within the transaction's timespan, there may be one or two episodes only partially included within the transaction's timespan. If there is an earlier but partially included episode, the delete transaction will do a {shorten backwards} transformation on it. If there is a later but partially included episode, the delete transaction will result in a {shorten forwards} transformation. In either case, the partially included episode may or may not have a partially included version; in other words, the transaction's timespan may or may not align on version boundaries. In either case, a partially included version is {split}, and the part outside the transaction's timespan is replaced.
[Equals]. If a temporal transaction's effective time [equals] that of one episode of the same object already in the target table, a temporal delete will {erase} that episode.
[Overlaps]. If a temporal delete transaction's effective time [overlaps] that of an episode, then either it begins after the episode begins and before it ends, and ends after the episode ends; or else it begins before the episode begins and ends after the episode begins but before it ends. In either case, the transaction will withdraw all versions wholly or partially included within the timespan of the transaction. At most one version can be partially included. If there is such a version, a temporal delete will replace the part of the partially included version that is outside the timespan of the transaction. The result is to either {shorten the episode backwards} or {shorten it forwards}, depending on whether the episode began before or after the transaction's timespan.
We have now demonstrated that every Allen relationship between a transaction and a target is valid for an insert, an update or a delete. So although we have not worked through a separate example for each Allen relationship, we can now be confident that there are no temporal precedence and succession relationships between a transaction's time period and that of a target episode that Asserted Versioning temporal transactions cannot handle.
A Temporal Extent Transformation Completeness Check
A second completeness check uses the taxonomy of Asserted Versioning temporal extent transformations presented in Chapter 9. After presenting that taxonomy, we argued there that the taxonomy is mutually exclusive and demonstrably complete. Its completeness was demonstrated by showing that all possible single-transformation topological transformations of two line segments are represented in the taxonomy.
Our second completeness check will use this taxonomy to review all extent-altering state transformations, and be sure that all of them can be brought about by valid temporal transactions.
This completeness check has proven to be easier to complete than we had originally anticipated. As indicated in Figure 10.21, all the transformations on the left-hand side of the diagram can be brought about by means of a temporal insert transaction. Indeed, each of those transformations was explicitly mentioned in the previous section. All the transformations on the right-hand side of the diagram can be brought about by means of a temporal delete transaction. Again, each of those transformations was explicitly mentioned in the previous section.
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 two taxonomies referenced in this chapter are included in this list. In general, we leave taxonomy nodes out of these lists since they are long enough without them.
12/31/9999
clock tick
Now()
until further notice
Allen relationships
adjacent
include
contiguous
asserted version table
Asserted Versioning Framework (AVF)
assertion begin date
assertion end date
assertion time
business data
effective begin date
effective end date
effective time
episode
episode begin date
open episode
lock
object
object identifier
oid
occupied
represented
past assertion
physical transaction
temporal transaction
temporal parameter
temporal insert transaction
temporal update transaction
temporal delete transaction
transaction timespan
proactive transaction
retroactive transaction
replace
supercede
withdraw
temporal entity integrity (TEI)
temporal referential integrity (TRI)
temporal extent state transformation
version
..................Content has been hidden....................

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