A foreign key establishes a link between two tables, namely between a 'foreign key table' and a 'reference table'. When the data in the reference table is changed or deleted, specific actions can automatically be done to the linked data on the foreign key table.
The link is established between the keys of the primary index (or the built-in LIONRECNO index) on the 'reference table' and specific fields on the 'foreign key table'. A table can have multiple foreign keys defined, thereby linking it to multiple reference tables.
To create a new foreign key, do the following:

|
Option: |
Description: |
Value: |
|
Name |
Name of the foreign key. |
<Text> |
|
Description |
Description of the foreign key. |
<Text> |
|
Reference table |
The table to which the foreign key references. This table can be picked from the dropdown list, which contains all tables that are available in the application. |
<Table name> |
|
Reference index |
The index that is related the reference table. The dropdown list only contains indexes having unique keys. |
<Index name> |
|
ON DELETE |
The action to be performed on the foreign key table when the associated record is deleted from the reference table. |
<Cascade | No Action | Set null> |
|
ON UPDATE |
The action to be performed on the foreign key table when the associated record is updated on the reference table. |
<Cascade | No Action> |
|
Table fields |
The fields that are available in the current table. |
<Field name> |
|
Reference fields
|
Key fields in the Reference index. Select from a dropdown list the key field from the reference index to associate with the field on the current table. |
<Field name> |
After a foreign key is added, adjusted or deleted, a Whole System generate is required, followed by a database reorganize.