Reprint: http://blog.csdn.net/u013215018/article/details/54981216
Now there are two tables, one is the roles table (the role table), the other is the Roleuser table (user role)
Now I want to set the Roleid property in the Roleuser table to a foreign key, associating the Roleid property in the Roles table.
Operation Steps:
The first step:
Step Two:
A total of seven columns. A brief introduction to the meaning of these columns:
"Name": You can not fill in, you will save a successful system will be automatically generated.
"Field": that is, which key you want to set as the foreign key. Choose ' Roleid ' here
Reference database: The database associated with the foreign key.
"Reference table": Associated table here is the roles table.
"Outer column name": The associated field, here is Roleid
"Delete": Is the action selected when the deletion. My choice here is setnull, meaning that when the associated table is deleted, the Roleuser->roleid field is set to null.
"On Update": Is the action selected when updating. My choice here is cascade, meaning that when the associated table is updated, the Roleuser->roleid field is set to cascade updates.
To add a foreign key constraint using Navicat for MySQL