Update and insert into temporal child table, delete from parent table These three scenarios differ in complexity for RI checking, and as a result, the measured  overhead also ranges 15.17% - 60.03%, as shown in Figure 7-22. To determine how efficient Db2 engine code is to enforce the RI relationship between parent  and child tables, we performed an experiment in which a row was inserted into a temporal  child table with Db2 enforced RI checking versus inserting that row into a child temporal table  where the RI is enforced by using triggers. The trigger that was used in this scenario is shown  in Example 7-31. Figure 7-22 RI checking overhead when updating and inserting into temporal child table, and deleting from parent table Db2 enforced RI checking versus trigger enforced RI checking Example 7-31 Trigger to enforce RI Chapter 7. SQL and application enablement  237 CREATE TRIGGER parent_child_RI_insert NO CASCADE BEFORE INSERT ON child REFERENCING NEW AS new_C FOR EACH ROW MODE DB2SQL BEGIN ATOMIC -- check if child row violate temporal RI  IF NOT EXISTS ( -- there was a row valid in PARENT when CHILD started SELECT * FROM PARENT AS P WHERE new_C.PID = P.PID AND P.BUS_START <= new_C.BUS_START AND new_C.BUS_START < P.BUS_END ) -- there was a row valid in PARENT when CHILD ended OR NOT EXISTS ( SELECT * FROM PARENT AS P WHERE new_C.PID = P.PID AND P.BUS_START < new_C.BUS_END AND new_C.BUS_END <= P.BUS_END ) -- there are no holes in PARENT.PID during Child's period of -- validity -- the outer select find all parents convers child's range -- for each this parent row -- the subselect in the predicate find if there is no gap