Home  >  Article  >  Database  >  How to set foreign keys in Navicat

How to set foreign keys in Navicat

angryTom
angryTomOriginal
2019-08-07 09:18:0520279browse

How to set foreign keys in Navicat

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, now that the basic situation is introduced, let’s start teaching you how to set foreign keys in navicat for mysql.

Recommended tutorial: MySQL database introductory video tutorial

##1. Open my navicat, and then find my teacher table, select it and 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

Extended content

Navicat is a fast, reliable and affordable database Management tools designed to simplify database management and reduce system management costs. It is designed to meet the needs of database administrators, developers and small and medium-sized enterprises. Navicat is built with an intuitive graphical user interface that allows you to create, organize, access and share information in a secure and easy way.

Navicat is world-famous and widely trusted by major enterprises, government agencies, and educational institutions around the world. It is also an essential daily working partner for practitioners from all walks of life. Since 2001, Navicat has been downloaded over 2,000,000 times worldwide and has a customer base of over 70,000 users. More than 100 Fortune 500 companies are using Navicat.

Navicat provides up to 7 languages ​​for customers to choose from and is recognized as the most popular database front-end user interface tool in the world.

 It can be used to manage and develop local or remote MySQL, SQL Server, SQLite, Oracle and PostgreSQL databases.

Navicat is powerful enough to meet all the needs of professional developers, and is easy to learn for those new to database servers. With an extremely complete graphical user interface (GUI), Navicat lets you create, organize, access and share information in a secure and simple way.

Navicat is available on three platforms - Microsoft Windows, Mac OS X and Linux. It allows users to connect to any local or remote server, and provides some practical database tools such as data model, data transfer, data synchronization, structure synchronization, import, export, backup, restore, report creation tools and plans to assist in managing data.

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!

Statement:
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