100% found this document useful (1 vote)
2K views

Integrity Constraints: Types of Integrity Constraint

Integrity constraints are rules used to maintain data quality by ensuring data is inserted, updated, and processed without affecting integrity. They guard against accidental database damage. There are several types of integrity constraints: domain constraints define valid value sets for attributes; entity integrity constraints require primary keys cannot be null; and referential integrity constraints require foreign keys in one table must match or be null in the referenced table's primary key. Key constraints uniquely identify entities using primary or other keys.

Uploaded by

pratibha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Integrity Constraints: Types of Integrity Constraint

Integrity constraints are rules used to maintain data quality by ensuring data is inserted, updated, and processed without affecting integrity. They guard against accidental database damage. There are several types of integrity constraints: domain constraints define valid value sets for attributes; entity integrity constraints require primary keys cannot be null; and referential integrity constraints require foreign keys in one table must match or be null in the referenced table's primary key. Key constraints uniquely identify entities using primary or other keys.

Uploaded by

pratibha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Integrity Constraints

o Integrity constraints are a set of rules. It is used to maintain the quality of


information.

o Integrity constraints ensure that the data insertion, updating, and other
processes have to be performed in such a way that data integrity is not
affected.

o Thus, integrity constraint is used to guard against accidental damage to the


database.

Types of Integrity Constraint

1. Domain constraints

o Domain constraints can be defined as the definition of a valid set of values for
an attribute.

o The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the
corresponding domain.

Example:
2. Entity integrity constraints
ADVERTISEMENT

o The entity integrity constraint states that primary key value can't be null.

o This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those
rows.

o A table can contain a null value other than the primary key field.

Example:

3. Referential Integrity Constraints

o A referential integrity constraint is specified between two tables.


o In the Referential integrity constraints, if a foreign key in Table 1 refers to the
Primary Key of Table 2, then every value of the Foreign Key in Table 1 must
be null or be available in Table 2.

Example:

4. Key constraints
ADVERTISEMENT

o Keys are the entity set that is used to identify an entity within its entity set
uniquely.

o An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the
relational table.

Example:

You might also like