Integrity Constraints over Relations
An integrity constraint (IC) is a condition specified on a database schema and restricts the data that can be stored in an instance of the database. If a database instance satisfies all the integrity constraints specifies on the database schema, it is a legal instance. A DBMS permits only legal instances to be stored in the database.
Many kinds of integrity constraints can be specified in the relational model:
Database integrity refers to the validity and consistency of stored data. Integrity is usually expressed in terms of constraints, which are consistency rules that the database is not permitted to violate.
Constraints may apply to each attribute or they may apply to relationships between tables.
Integrity constraints ensure that changes (update deletion, insertion) made to the database by authorized users do not result in a loss of data consistency. Thus, integrity constraints guard against accidental damage to the database.
EXAMPLE- A brood group must be ‘A’ or ‘B’ or ‘AB’ or ‘O’ only (can not be any other values else).
TYPES OF INTEGRITY CONSTRAINTS
Various types of integrity constraints are-
- Domain Integrity
- Entity Integrity Constraint
- Referential Integrity Constraint
- Key Constraints
- Domain Integrity- Domain integrity means the definition of a valid set of values for an attribute. You define data type, length or size, is null value allowed , is the value unique or not for an attribute ,the default value, the range (values in between) and/or specific values for the attribute.
- Entity Integrity Constraint- This rule states that in any database relation value of attribute of a primary key can’t be null.
EXAMPLE- Consider a relation “STUDENT” Where “Stu_id” is a primary key and it must not contain any null value whereas other attributes may contain null value e.g “Branch” in the following relation contains one null value.
3.Referential Integrity Constraint-It states that if a foreign key exists in a relation then either the foreign key value must match a primary key value of some tuple in its home relation or the foreign key value must be null.
4.Key Constraints- A Key Constraint is a statement/condition that a certain minimal subset of the fields of a relation is a unique identifier for a tuple.
There are 4 types of key constraints-
- Candidate key.
- Super key
- Primary key
- Foreign key
- relational model
- relational model database
- relational model diagram
- relational model example
- relational model vs dimensional model
- relational models theory
- relational model of data
- relational model sql
- relational model of disability
- relational model vs entity relationship model
- integrity constraints
- integrity constraints in sql
- integrity constraints are enforced by
- integrity constraints example
- integrity constraints in oracle
- integrity constraints over relations
- integrity constraints in er diagram
- integrity constraints in dbms in hindi
- integrity constraints in rdbms
- integrity constraints in distributed database