A foreign key is a field in a relational table that matches the primary key column of another table. The foreign key can be used to cross-reference tables.
Foreign Keys are managed on the Foreign Keys tab of the Table Designer. Just simply click/double-click a foreign key field for editing. A right-click displays the popup menu or using the toolbar below, allowing you to create new, edit and delete the selected foreign key field.
Note: Foreign Key support from MySQL 3.23.44 or later.
Add Foreign Key
To add a foreign key
- Open the table in the Table Designer.
- Open the Foreign Keys tab.
- Right-click and select the
Add Foreign Key from the popup menu or click the
Add Foreign Key from the toolbar.
- Edit foreign key properties.
Note: Both tables must be InnoDB type (or solidDB type if you have solidDB for MySQL). In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Starting with MySQL 4.1.2, such an index will be created on the referencing table automatically if it does not exist.
Edit Foreign Key
To edit a foreign key
- Open the table in the Table Designer.
- Open the Foreign Keys tab.
- Just simply click/double-click on the foreign key to edit.
Note: Support from MySQL 4.0.13 or later.
Delete Foreign Key
To delete a foreign key
- Open the table in the Table Designer.
- Open the Foreign Keys tab.
- Right-click on the foreign key to delete and select the
Delete Foreign Key from the popup menu or click the
Delete Foreign Key from the toolbar.
- Confirm deleting in the dialog window.
Note: Support from MySQL 4.0.13 or later.
See also:
Setting Foreign Key Name and Table Fields
Setting On Delete and On Update Actions
Related topic:
Foreign Keys Data Selection