RELATIONAL MODEL – Integrity Constraints

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-

  1. Domain Integrity
  2. Entity Integrity Constraint
  3. Referential Integrity Constraint
  4. Key Constraints
  1. 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.

 

  1. 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.

Stu_id Name Branch
11255234 Aman CSE
11255369 Kapil ECE
11255324 Ajay
11255237 Raman CSE
11255678 Aastha ECE

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-

  1. Candidate key.
  2. Super key
  3. Primary key
  4. Foreign key

See also

Relational database

Computer Professional Bodies

CAREER OPPORTUNITIES IN DATA PROCESSING

SOURCES OF COMPUTER INFECTION VIRUS | WARNING SIGNS, PREVENTIVE, ANTIVIRUS

COMPUTER VIRUS | TYPES, EXAMPLES, EFFECTS

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Fully Funded Scholarships

Free Visa, Free Scholarship Abroad

           Click Here to Apply

Acadlly