Online Documentation for SQL Manager for SQL server

Creating/editing foreign key


Use the Foreign Key tab of Foreign Key Editor to create/edit a foreign key constraint and specify its properties.

 

Name

Enter a name for the new foreign key, or modify the name of the foreign key being edited.

 

Table

The drop-down list of tables allows you to select the table for which the foreign key is created.

 

Foreign Key Editor - Editing foreign key definition

 

 

The Table Fields area allows you to select Foreign key field(s).

To select a field, you need to move it from the Available Fields list to the Included Fields list. Use the Move to Selected Move to Available buttons or drag-and-drop operations to move the fields from one list to another.

 

Foreign table

Use the drop-down list to select the foreign table.

 

The Foreign Table Fields area allows you to select the field(s) of the Foreign table.

To select a field, you need to move it from the Available Fields list to the Included Fields list. Use the Move to Selected Move to Available buttons or drag-and-drop operations to move the fields from one list to another.

 

If the referenced column(s) are changed frequently, it may be wise to add an index to the foreign key column so that referential actions associated with the foreign key column were performed more efficiently. See Indexes for details.

 

 

Update action / Delete action

  • No action

Produce an error indicating that the deletion or update would create a foreign key constraint violation. If the constraint is deferred, this error will be produced at constraint check time if there still exist any referencing rows. This is the default action.

  • Cascade

Delete any rows referencing the deleted row, or update the value of the referencing column to the new value of the referenced column, respectively.

  • Set NULL

Set the referencing column(s) to null.

  • Set default

Set the referencing column(s) to their default values.

 

 

CheckBox Enabled

Enables/disables the foreign key immediately after it is created.

 

CheckBox Check existing data

This option specifies whether the data in the table is or is not validated against a newly added or re-enabled foreign key.

 

CheckBox Not for replication

This option allows you to specify that the foreign key should not be enabled when a replication agent modifies the table that is involved in the foreign key.