-- -----------------------------------------------
-- USING SQL TO DEVELOP TIME ORIENTED APPLICATIONS
-- By : Richard T. Snodgrass
-- -----------------------------------------------
--
-- Referential Integrity for temporal tables
-- By   : Bruce C. Huang
-- Date : Dec. 12, 1997
--
-- -----------------------------------------------
REM
REM Code Fragment 5.13
REM Oracle 7.3 Version
REM
REM Drop POSITIONS if already exists
Drop Table POSITIONS;

Create Table POSITIONS(
  PCN             VARCHAR2(6),
  JOB_TITLE_CODE1 NUMBER(10),
  START_DATE      DATE,
  END_DATE        DATE,
  UNIQUE(PCN, END_DATE)
 )
;

REM Drop INCUMBENTS if already exists
Drop Table INCUMBENTS;

Drop Table INCUMBENTS;
Create Table INCUMBENTS(
  SSN		VARCHAR2(11),
  PCN		VARCHAR2(6),
  START_DATE    DATE,
  END_DATE      DATE,
  FOREIGN KEY(PCN,END_DATE) REFERENCES POSITIONS(PCN,END_DATE)
 )
;
