CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Define foreign key. How is this concept useful in relational data model? Illustrate with suitable example.

Open in App
Solution

A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.
While key and entity constraints are specified on individual relation, the referential integrity constraint is specified between two or more relations. This constraint is specified to maintain consistency among the tuples of such relations. Accordingly, a tuple in one relation that refers to another relation must refer to an existing tuple in that other relation.

In referencing Accounts Type, Accounts relation uses its attribute. Type, which acts as foreign key to reference the tuples of relation Accounts Type through its primary key CatId. The value of Type cannot be null because of total participation of Accounts in classify relationship.

Say e.g., there are two tables EMP (EMPNO, ENM, SAL, DPTNO(Foreign Key))

DEPT (DPTNO {Primary Key}, DNM, LOC)

The foreign key DPTNO of EMP Table takes its value as a reference from DEPT TABLE DPTNO.


flag
Suggest Corrections
thumbs-up
2
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Database Structuring
ACCOUNTANCY
Watch in App
Join BYJU'S Learning Program
CrossIcon