Using integrity constraints, you can specify foreign keys in a referencing table that point to certain primary keys or other unique keys in a referenced table. Once the constraints are defined, the Query Processor enforces referential integrity on any updates to the database using SQL interfaces. SQL updates do not leave dangling references to nonexistent records.
In a relational referential integrity constraint, one or more foreign keys in the referencing table are checked against one or more primary keys in the referenced table. SQL ensures that the data contained in the foreign key columns of the referencing table are consistent with the data contained in the primary key columns of the referenced table.
| Note: | Native Enterprise Database Server applications are not affected by referential integrity constraints added to an existing Enterprise Database Server database using Relational Design Center. If you add referential constraints to an Enterprise Database Server database through Relational Design Center, the enforcement only occurs when update, delete, or insert actions are executed through SQL statements. This might result in inconsistent data for databases updated by non-SQL applications. |
Perform the following steps to create an integrity constraint for a table:
| Note: | This task applies only to an Enterprise Database Server database that is mapped to SQL. |
-
From the tree view, expand the server containing the database you want to modify.
-
Expand the database and expand the data set for which you want to create a constraint.
-
Click the Constraints node.
An input form appears in the properties view.
-
Type a name for the constraint in the Referential Integrity Constraint Name box.
-
Select a foreign key for the referencing table from the Foreign Key Item list.
Note: If the table does not contain any foreign keys, the Foreign Key Item list is unavailable. -
Select a table from the Referenced Table list.
-
Select a primary key from the Primary Key Item list.
Note: If the table does not contain any primary keys, the Primary Key Item list is unavailable. -
Click Add Key Pair to add the foreign key item and primary key item to the table.
If more than one foreign key and primary key pair is required for the constraint, you can add additional key pairs by selecting the items from the appropriate list and then clicking Add Key Pair.
If you want to remove a key pair from the constraint, select the appropriate key pair row from the table and click Delete Key Pair.
-
Click Store.
The new constraint is added to the tree view immediately, and the constraint is added to the database schema when you apply modifications to the database. Refer to Applying Schema Modifications earlier in this section for information on applying schema modifications.

