17.10 - Example: Reduce Discount occurs before Increase Order - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Temporal Table Support

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1182-171K
Language
English (United States)

Assume the individual transactions have the following characteristics:

Times Increase Order Transaction Reduce Discount Transaction
Begin Time 2009-01-05 2009-01-02
Modification Time 2009-01-10 2009-01-03
End Time 2009-01-11 2009-01-04

Notice that Reduce Discount ends before Increase Order begins.

The following shows the states of the Parts and Orders tables after transactions have completed.

Parts Table after the Reduce Discount transaction:

Part_ID Supplier_ID Price Discount Part_Validity
P1 S1 $10 10% (2008-01-01, 2009-01-02)
P1 S1 $10 5% (2009-01-02, 2011-01-01)

In the original state of the tables, the P1 rows qualified for the CURRENT transaction because their valid times overlapped TEMPORAL_DATE.

Additionally, the P1 row in the Parts table was modified, because the P1 row in the Orders table fulfilled the transaction WHERE test (quantity < 100).

The modification of the P1 row in the Parts table leaves a history row showing the state of the row prior to the modification. Notice the end time of the first row and the beginning time of the second row have both been timestamped with TEMPORAL_DATE at the time of the modification.

Orders table after Increase Order transaction:

Order_ID Part_ID Quantity Order_Validity
O1 P1 60 (2008-01-01, 2011-01-01)

The row was not changed, because the current time at the time of the Increase Order transaction was 2009-01-05. Using this current time, only the second row in the Parts table qualifies for the transaction, however that row fails the WHERE test (discount >= 10), due to the changes made by the preceding Reduce Discount transaction.