Primary Key

There cannot be any instant where two or more rows have the same values for the primary key columns. Primary key for event sets can be described in plain SQL, but state sets demand a complex trigger.

Pandamator does not support other unique constraints, primarily because I don't use them and couldn't justify the cost of supporting them.

Primary key violation example

Primary key violation example:

(In this and the following such diagrams, time increases to the right.) There are two entities (named A) with the same values for their primary key, overlapping during the period shown in blue.

Foreign Key

There cannot be any instant where a row in the referencing table does not correspond to a row in the referenced table.

Pandamator does not support other unique constraints, so a foreign key can only refer to a primary key.

Foreign key violation example:

Entity B has a foreign key towards entity A, but entity A does not exist during the period shown in grey.

Foreign key violation example

Foreign Key is characterized by a delete rule, prescribing what happens during a DELETE. I don't encourage updates to primary keys, consequently Pandamator does not support update rules on Foreign Keys.

On Delete Cascade
Foreign key Cascade example

Deletion of A cascades to B for the deletion period, breaking B up as needed.

On Delete Set Null

Deletion of A sets the foreign key on B to NULL for the deletion period, breaking B up as needed. In the example, a period of B shown in blue, is broken up into three periods, the middle one shown in light blue having NULL as foreign key.

Foreign key Set Null example
On Delete Restrict
Foreign key Restrict example

Deletion of A is inhibited if a foreign key exists to it at any time during the deletion period.

Contiguous History

This is just a handy constraint to ensure that a state set does not have gaps in its history. In other words, between two instants when an entity does exist with a specific primary key, there cannot be any instant when that entity does not exist.

Contiguous History violation example:

Entity A has a gap in its history, during the period shown in grey.

Contiguous History violation example