Friday, 22 May 2015

INTEGRITY RULES IN DBMS

Integrity  Rules:

Database Management System  provides  high level of data integrity, by using the  Integrity Rules:

1. Entity Integrity: Entity integrity says that  a prime attribute in a relation cannot accept null values or duplicate value.
2. Referential Integrity: The referential integrity rule is related along with the foreign key concept. Let R1 and R2 are two relations where R1 is having an attribute(s) with primary key. Let R2 be having a foreign key, that refers to relation R1 via the same set of attributes. Then the value of the foreign key in a tuple in R2 relation must either be equal to primary key of a tuple in a relation R1 relation or be entirely NULL.
R1
Department_ID
Department_Name
Department_Head
Department_Addres
D1
HR
Jacob
London
D2
IT
Rohan
Newyork
D3
FINANCE
Michel
Delhi

R2
EMP_ID
EMP_Name
EMP_City
Department_ID
E1
Rohan

D2
E2
Mukesh

D1
E3
Joseph

D1
E4
Ron

D1
E5
Michel

D3
E6
Jacob

D1
In above example  , in relation R1  Department_ID  is primary key  where as in R2 Department_ID is foreign key.


Value of the foreign key in R2 is same as Value exist in R1 of primary key.

No comments: