Home > Database > navicat > How to set foreign keys in navicat

How to set foreign keys in navicat

angryTom
Release: 2019-08-05 10:21:48
Original
5147 people have browsed it

How to set foreign keys in navicat

I just figured out how to set foreign keys on navicat for mysql this morning. Now I share it. I hope it will be helpful to everyone.

Recommended tutorial: MySQL introductory video

Let me first introduce the basic situation. Now there are two tables, one is the teacher table and the other is the dept table. Now I want to set the dept attribute in the teacher table as a foreign key and associate the code attribute in the dept table. The specific situation is as shown in the figure; OK, the basic situation is introduced, now let’s teach you how to set foreign keys in navicat for mysql.

How to set foreign keys in navicat

1. Open my navicat, then find my teacher table, select it, and then click ‘design table’ on the menu bar.

How to set foreign keys in navicat

#2. Find "Foreign Keys" in the pop-up dialog box, and then stand alone.

How to set foreign keys in navicat

#3. Then an interface for setting foreign keys will appear, with a total of seven columns. Let’s briefly introduce the meaning of these columns.

‘name’: You don’t need to fill it in. The system will automatically generate it after you save it successfully.

‘FieldName’: Which key you want to set as a foreign key. Select ‘dept’

here. ‘Reference DadaBase’: the database associated with the foreign key.

 'Reference Table': The associated table, here is the dept table

 'Forgin filed Names': The associated field, here is the code

 'ondelete': It is deleted action when selecting. My choice here is setNull, which means that when the associated table is deleted, the teacher>dept field will be set to null.

‘onupdate’: It is the action selected when updating. My choice here is CASCADE, which means that when the associated table is updated, the teacher>dept field will be set to cascade update.

How to set foreign keys in navicat

#4. After the settings are completed, click ‘save’ to save and exit. You can also click ‘add Foreign Key’ to add another foreign key.

How to set foreign keys in navicat

The above is the detailed content of How to set foreign keys in navicat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template