Referential integrity and tables

 

Referential integrity is the condition of a set of tables in a database in which all references from one table to another are valid.

Consider the following example:

Other tables refer to the same entities described in these tables. When a table contains data for which there is a master list, that data should actually appear in the master list, or the reference is not valid. The table that contains the master list is the parent table, and the table that refers to it is a dependent table. When the references from the dependent table to the parent table are valid, the condition of the set of tables is called referential integrity.

Stated another way, referential integrity is the state of a database in which all values of all foreign keys are valid. Each value of the foreign key must also exist in the parent key or be null. This definition of referential integrity requires an understanding of the following terms:

Enforcement of referential integrity prevents the violation of the rule that states that every non-null foreign key must have a matching parent key.

SQL supports the referential integrity concept with the CREATE TABLE and ALTER TABLE statements.

 

Parent topic:

Creating a table

 

Related reference


DB2 Universal Database for iSeries sample tables
CREATE TABLE
ALTER TABLE