what are the integrity rules?


what are the integrity rules?

amit Reviewer Asked on June 8, 2015 in Databases.
Add Comment
3 Answer(s)

There are two Integrity rules.

  1. Entity Integrity: States that “Primary key cannot have NULL value”
  2. Referential Integrity: States that “Foreign Key can be either a NULL value or should be Primary Key value of other relation.


padma Supporter Answered on June 8, 2015.
Add Comment

 

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.


alex Reviewer Answered on June 8, 2015.
Add Comment

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.


Rohit Reviewer Answered on June 8, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.