Database Management System: Unit I: Relational Databases

Database Integrity

Relational Databases - Database Management System

The foreign key is a key in one table that refers to the primary key of another table. The foreign key is basically used to link two tables.

Database integrity

The foreign key is a key in one table that refers to the primary key of another table.

The foreign key is basically used to link two tables. For example

Consider Customer table as follows –

Note that the "CustID" column in the "Order" table points to the "CustID" column in the "Customer" table.

The "CustID" column in the "Customer" table is the PRIMARY KEY in the"Customer" table.

The "CustID" column in the "Order" table is a FOREIGN KEY in the "Order" table.

The table containing the foreign key is called the child table, and the table containing the primary key is called the referenced or parent table.

The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.

The FOREIGN KEY constraint also prevents invalid data from being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.

Database Management System: Unit I: Relational Databases : Tag: : Relational Databases - Database Management System - Database Integrity