Start page / Templates (basics) / Composition of templates / Database schemata / Schema editor / Create foreign key
Creating a foreign key relationship
The process of creating a relationship will be explained using the example of the company database. We want to create a relationship between the tables called Products and Contacts: One contact person can be assigned to multiple products, i.e. they are in a 1:N relationship.
First of all, the Contacts and (while pressing the Shift key) Products tables have to be activated (activated tables change their frame color). Then, if the Create foreign key relation icon is selected, a window for defining the relationship appears:
Type of relationship:
The radio buttons are used to define the nature of the relationship. The two tables should be in a 1:N relationship.
Source:
Source table: This field specifies the table that serves as the starting point for the relationship (in our example: the Contacts table, which was the one we selected first). If necessary, another table from the schema can be selected via the combo box.
Column name: This field contains a name for the column that is to be used to establish the relationship. The name is suggested by the system, but can be changed if necessary. This name will be subsequently used to track the datasets over the course of their relationships.
Target:
Target table: This field specifies the table to which the relationship leads (in our example: the Products table, which was the one we selected last). If necessary, another table from the schema can be selected via the combo box.
Column name: This field contains a name for the column that is to be used to establish the relationship. The name is suggested by the system, but can be changed if necessary. This name will be subsequently used to track the datasets over the course of their relationships.
Options:
Aggregation (dependent Delete/Release): If this option is checked, the deletion/release of a dataset also causes the linked dataset from the other table to be deleted/released at the same time.
From FirstSpirit version 5.1R3 on the source and target table can be swapped in this dialog by using the icon .