Let us understand the concept of Entity Integrity and Referential Integrity. Before proceeding further, we recommend to read these article for better understanding:
Entity means any place, thing or person in database. An entity represents a real world object. Each table represents an entity and each row in a table is the instance of entity.
Entity Integrity constraint uniquely identifies each row in table. Primary key assures the entity integrity constraint is applied to a table.
It also states that value in primary key fields cannot be null.
For example, Let us take example of table Employee having columns: Emp_Id, Name, Address, Pincode, Passport_Number, Salary.
Let’s say Emp_Id is primary key in the table. Thus from the definition of Entity Integrity, the value of Emp_Id cannot be null as it unique identifies an employee record in the table.
Thus no primary key column of any row in a table can have a null value.
Referential integrity constraint refers to relationship between the tables. The relationship between tables is established by using foreign keys. This constraint states that a foreign key must have a matching primary key in another table or must be null.
For example, let’s say we have table SC that tells us which student study in which class. We also have Student and Class tables.
Thus every foreign key must contain a null value or a valid key reference in another table.
Download as PDF
Read next: Normalization ››
« Back to Course page
Punjab Civil Services 2021