Create a foreign key to constrain a column based on values in a reference table.
A foreign key:
- is a column or combination of columns that have values that match the primary
key,
- does not need to be unique.
- is often in a many to-one relationship to a primary key
- may be null; if any part of a composite foreign key is null, the entire foreign key
must be null.
- In the left pane of the Administration Console, expand , then choose one of the following:
- Click the Name field of the table, then click the drop-down arrow and select
Properties.
- In the left pane, click Foreign Keys.
- Select New.
- On the Referenced Table screen:
- Select the database that contains the table that the foreign key
references.
- Select the referenced table of the foreign key,
- Provide a name for the foreign key.
- On the Referenced Column screen:
- Select the key to which the foreign key references.
- Select columns from the Foreign Key Column to match to columns in Primary Key
Column.
Foreign key values should be copies of the primary key values. No
value in the foreign key should exist unless the same value exists in the
primary key.
- (Optional) Click Summary to review your selected
options.
- Click Finish .