Chapter 5. Temporal data management and analytics in an operational warehouse 223
Figure 5-50 shows the history table for this bitemporal table. As expected, the
layout of the HISTORY table is identical to the base bitemporal table.
Figure 5-50 Bitemporal HISTORY table for CUST_LOYALTY
If we run a few simple INSERT and UPDATE statements on our bitemporal
CUST_LOYALTY table as shown in Example 5-31, we can view the impact on the
base and HISTORY tables. We see that we INSERT four new customer records,
then UPDATE one of the records (Linda MM) to give her the promotional bonus
rate for 30 days.
Example 5-31 SQL to populate the bitemporal CUST_LOYALTY table
insert into cstinsight.cust_loyalty ("Customer", "Loyalty_Scheme", "Bonus_Pct",
"Effective_Start_Date", "Effective_End_Date")
values('Albert Johnson', 'Customer Loyalty Club', 100, '2011-09-15',
'9999-12-30');
insert into cstinsight.cust_loyalty ("Customer", "Loyalty_Scheme", "Bonus_Pct",
"Effective_Start_Date", "Effective_End_Date")
values('Joe Smith', 'No Loyalty Scheme', 0, '2012-06-22', '9999-12-30');
insert into cstinsight.cust_loyalty ("Customer", "Loyalty_Scheme", "Bonus_Pct",
"Effective_Start_Date", "Effective_End_Date")
values('Linda MM', 'Customer Gold Club', 150, '2012-03-12', '9999-12-30');
insert into cstinsight.cust_loyalty ("Customer", "Loyalty_Scheme", "Bonus_Pct",
"Effective_Start_Date", "Effective_End_Date")
values('Melissa Smith', 'Customer Loyalty Club', 100, '2011-11-01',
'9999-12-30');
UPDATE "CSTINSIGHT"."CUST_LOYALTY"
FOR PORTION OF BUSINESS_TIME FROM
'2012-08-01' TO DATE('2012-08-01') + 30 DAYS
SET "Bonus_Pct" = 200