The two principal rules for the relational model are as follows:
• Entity integrity: this is used to maintain the integrity at entity level
• Referential integrity: it is used to maintain integrity on all the values which have been referenced.
The differences between them are as follows:
• Entity integrity tells that in a database every entity should have a unique key; on the other hand referential integrity tells that in the database every table values for all foreign keys will remain valid.
• Referential integrity is based on entity integrity but it is not the other way around.
For example: if a table is present and there is a set of column out of which one column has parent key set then to ensure that the table doesn’t contain any duplicate values, a unique index is defined on the column that contains the parent key.