To add a foreign key constraint using Navicat for MySQL

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.