You can establish referential integrity between tables in the current database. If no database is specified, you can establish referential integrity between tables in the current directory.

To define a referential integrity relationship,

  1. In the Navigator, Tables page, use the Look In box to select a database alias or a directory containing tables (such as .DBF or .DB type) that support referential integrity.

One-to-one relationships can be defined between the primary key field in the parent and the primary key field in the child, or any field in the child that has a unique index.

One-to-many relationships can be defined between an indexed field that is not the primary key in the child and the primary key field in the parent.

You can establish referential integrity with a complex (or composite) key. If the parent table has a complex key, add fields from the Fields list to match all of the fields in the parent’s key.

Note

If you attempt to define referential integrity on a table that already contains data, some existing values may not match a value in the parent’s key field. When this happens, the operation fails and you receive an error message.

Update and delete behavior

You can specify the following rules for updating and deleting data in a parent table that has dependent rows in a child table:

Restrict: You cannot change or delete a value in the parent’s key if there are rows that match the value in the child table.

For example, if the value 1356 exists in the Customer No field of Orders, you cannot change that value in the Customer No field of Customer. (You can change it in Customer only if you first delete or change all rows in Orders that contain it). If, however, the value doesn’t exist in any rows of the child table, you can change the parent table.

Cascade: Any change you make to the value in the key of the parent table is automatically made in the child table. If you delete a value in the key of the parent table, dependent rows in the child table are also deleted.

The availability of cascading updates and deletes varies according to the table type:

dBASE Level 7: Cascading updates or deletes permitted

Paradox: Cascading updates only

Oracle: Cascading deletes only

Sybase: No cascading updates or deletes permitted

InterBase: No cascading updates or deletes permitted

Microsoft SQL Server: No cascading updates or deletes permitted