Jump to content

Integrity constraints

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 14.98.2.54 (talk) at 04:12, 12 June 2013 (User Defined Integrity). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Integrity constraints are used to ensure accuracy and consistency of data in a relational database.[citation needed] Data integrity is handled in a relational database through the concept of referential integrity. There are many types of integrity constraints that play a role in referential integrity.

Types

Codd initially defined two sets of constraints but, in his second version of the relational model, he came up with four integrity constraints: [citation needed]

Entity integrity

The entity integrity constraint states that no primary key value can be null. This is because the primary key value is used to identify individual tuples in a relation. Having null value for the primary key implies that we cannot identify some tuples.This also specifies that there may not be any duplicate entries in primary key column key word


Referential Integrity

The referential integrity constraint is specified between two relations and is used to maintain the consistency among tuples in the two relations. Informally, the referential integrity constraint states that a tuple in one relation that refers to another relation must refer to an existing tuple in that relation. It is a rule that maintains consistency among the rows of the two relations.

Domain Integrity

The domain integrity states that every element from a relation should respect the type and restrictions of its corresponding attribute. A type can have a variable length which needs to be respected. Restrictions could be the range of values that the element can have, the default value if none is provided, and if the element can be NULL.

User Defined Integrity

A business rule is a statement that defines or constrains some aspect of the business. It is intended to assert business structure or to control or influence the behavior of the business. E.g.: Age>=18 && Age<=60

See also

References