what are the integrity rules?
Entity Integrity – Every table requires a primary key.
The primary key, nor any part of the primary key, can contain NULL values. This is because NULL values for the primary key means we cannot identify some rows. For example, in the EMPLOYEE table, Phone cannot be a key since some people may not have a phone.
Referential integrity – a foreign key must have a matching primary key or it must be null
This constraint is specified between two tables (parent and child); it maintains the correspondence between rows in these tables. It means the reference from a row in one table to other table must be valid.
Integrity Rules are imperative to a good database design. Most RDBMS have these rules automatically, but it is safer to just make sure that the rules are already applied in the design. There are two types of integrity mentioned in integrity rules, entity and reference.
Entity integrity exists when each primary key within a table has a value that is unique. this ensures that each row is uniquely identified by the primary key.One requirement for entity integrity is that a primary key cannot have a null value. The purpose of this integrity is to have each row to have a unique identity, and foreign key values can properly reference primary key values.
Reference integrity exists when a foreign contains a value that value refers to an exiting tuple/row in another relation. The purpose of reference integrity is to make it impossible to delete a row in one table whose primary key has mandatory matching foreign key values in another table.