Navicat How to set foreign keys

Source: Internet
Author: User

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.

  1. Open My navicat, then find my teacher table, select it, and then click ' Design Table ' on the menu bar.

  2. 2

    In the popup dialog box, locate "Foreign Keys" and then stand alone.

  3. 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. 4

    Click ' Save ' to save the settings and click ' Add Foreign key ' to add a foreign key.

  5. 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

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.