/  Technology   /  Referential Integrity

Referential Integrity

Referential Integrity

Let there be two relations R1 and R2. If a value of a set of attributes (A) in relation R1, also appears for a certain set of attributes (A) in other relation R2, then, that concept is known as ‘ referential integrity ’.

 

Here, the set of attributes (A) in R2 is called ‘Primary Key’.

Here, the set of attributes (A) in R1 is called ‘Foreign Key’.

  

Requirements of this form are called ‘Referential Integrity Constraints’.

 

Example:

 Consider the following two relations.

 

        R1 :  STUD                                                 R2 : DEPT

SNo SName       DNo                     DNo         DName

121 xyz              21                           21               CSE

123 pqr              21                           22               IT

126 mnp            22                           23               ECE

128 abc             22                           24               ME

130 jkl                23                           25               EEE

———————————-                     —————————-

 Here, R1 is called ‘referencing relation’.

And  R2 is called ‘referenced relation’.

 

The attribute ‘DNo’ in STUD is called ‘Foreign Key’.

The attribute ‘DNo’ in DEPT is called ‘Primary Key’.

               Create command for STUD relation :

                     Create  table  STUD

                                 (…….

                                 Foreign key (DNo) references DEPT

Leave a comment