Define a foreign key

Define a foreign key by using the New Table Definition wizard. A foreign key consists of one or more columns in a table whose value in one row uniquely identifies another row in the same or another table.

When you create a table, you can define the foreign keys after you have defined the columns for the table as well as the target. The target of the foreign key is another table and its primary key.

To define foreign keys for a table:

  1. On the Foreign Keys page of the New Table Definition wizard, click Add another to add foreign keys to the table. You will see the foreign keys added to the Foreign Keys list. When a foreign key is selected in the list, several property fields appear to the right of the Foreign keys list.

  2. Optional: Provide a name for the foreign key. If you do not name the key, a default name is generated.

  3. Set the behavior for the foreign key when update or delete operations are made. The delete and update properties might not be available depending on the database vendor.

  4. In the Target Table field, you can either select the table that you want the foreign key to reference or browse for a target table.

  5. Select the columns you want to include as part of the key from the list of source columns on the left.

  6. Click > to add these columns to the foreign key list on the right. The number and type of the columns in the foreign key must match the number and type of columns in the target table's primary key. If the user has not yet specified the correct number of columns, a message will be shown at the top of the page.

  7. Click Finish. The table is added to your database.

You can add, delete, or change foreign keys afterwards by using the table editor. To open the table editor, double-clicking on the table in the Data Definition view.

 

Parent topic

Defining a table