search
HomeTopicsAccessIn a database, what maintains the relationship between tables?

In a database, what maintains the relationship between tables?

Foreign Key. When the primary key of a two-dimensional table (such as table A) is included in another two-dimensional table (such as table B), table A The primary key in becomes the foreign key of table B.

Foreign keywords represent the connection between two relationships. The table with the foreign key of another relationship as the primary key is called the master table, and the table with the foreign key is called the slave table of the master table. Foreign keywords are also called foreign keys.

Validity of foreign keys

Many times, programmers will find that fields are missing, redundant, or that they cannot add unconstrained fields after creating foreign keys. [This is necessary in special circumstances]. If you don’t want to operate on the table structure at this time, you can use constraint invalidation.

Take Northwind as an example: I want to add a piece of data to the product table [Products table] that is not restricted by the category table [Categories table]. You can invalidate the Categories constraint in the products table.

Writing method:

ALTER TABLE dbo.Products NOCHECK CONSTRAINT FK_Products_Categories

After the addition is completed, make it valid:

ALTER TABLE dbo.Products CHECK

This completes the addition of data that is not constrained by a certain table.

Another benefit is: as in the above example. When modifying the Categories table or adding fields, all foreign keys that reference the Categories table must be invalidated. After adding fields to the Categories table, restore validity to all foreign keys that apply to the Categories table.

For more related knowledge, please visit: PHP Chinese website!

The above is the detailed content of In a database, what maintains the relationship between tables?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment