Example of WHEN or THEN Constraints
A concrete example showing how SQL supports WHEN/THEN constraints
CREATE TABLE SAL_HISTORY (EmpNo CHAR (6),
Salary INTEGER NOT NULL,
PERIOD FOR During (From, To),
PRIMARY KEY (EmpNo, During WITHOUT OVERLAPS)
The PERIOD FOR specification states that the From and To values in each row denote a time interval (called a period because SQL uses the term "interval" for something else). The From values are treated as closed bounds, the To values as open bounds, so a given row in SAL_HISTORY indicates that an employee was paid a certain salary from the given From date up to but not including the given To date. The specification implies the column constraint NOT NULL NOT DEFERRABLE ENFORCED for each of columns From and To. During WITHOUT OVERLAPS, which, if required, must appear as the last element of the key, specifies that if the same EmpNo value appears in two distinct rows of SAL_HISTORY, then the From and To values in those rows must denote During periods that do not overlap (have no date in common).