This morning just figured out how to set the foreign keys on Navicat for MySQL, and now share them, hoping to be helpful to everyone.
Let me introduce you to the basic situation. Now there are two tables one is the teacher table one is the Dept table, and now I want to set the Dept property in the Teacher table to the foreign key, associating the Code property in the Dept table. Well, the basics are over, and now it's time to teach you navicat for MySQL how to set foreign keys.
Open My navicat, then find my teacher table, select it, and then click ' Design Table ' on the menu bar.
- 2
In the popup dialog box, locate "Foreign Keys" and then stand alone.
- 3
Then there will be an interface to set the foreign key, with a total of seven columns. A brief introduction to the meaning of these columns.
' Name ': Can not fill, you will save a successful system will be generated automatically.
' FieldName ': is the key you want to set as a foreign key. Choose ' Dept ' here
' Reference dadabase ': The database associated with the foreign key.
' Reference table ': Associated tables here is the Dept table
' Forgin filed Names ': The associated field, here is the code
' OnDelete ': Is the action you choose when you delete. My choice here is setnull, meaning that when the associated table is deleted, the Teacher Dept field is set to null.
' OnUpdate ': is the action of choice when updating. My choice here is cascade, meaning that when the associated table is updated, the Teacher Dept field is set to cascade updates.
- 4
Click ' Save ' to save the settings and click ' Add Foreign key ' to add a foreign key.
- 5
How to set the foreign key is so simple. Just try it yourself. Remember to click ' useful '. Thank you
Navicat How to set foreign keys