Integrity Constraints in DBMS

Integrity Constraints

  • The Set of rules which is used to maintain the quality of information are known as integrity constraints.
  • Integrity constraints make sure about data intersection, update and so on.
  • Integrity constraints can be understood as a guard against unintentional damage to the database.

 

Different types of Integrity Constraints

Domain Constraint

  • The Definition of an applicable set of values is known as domain constraint.
  • Strings, character, time, integer, currency, date etc. Are examples of the data type of domain constraints.

Example

IDNAMESEMESTERAGE
100Jai1st27
101BKadam4th34
102Rajeev3rd31
103Asmita6th29
104Mahesh2ndTwenty two

‘Twenty two’ is not allowed for 104 id because the attribute AGE is an integer

 

Entity Integer Constraint

  • Entity Integrity Constraints states that the primary value key cannot be null because the primary value key is used to find out individual rows in relation and if the value of the primary key is null then it is not easy to identify those rows.
  • There can be a null value in the table apart from the primary key field.

Example

Emp_IDEmp_NameSalary
11Manish30000
12Vikram20000
13Sudhir10000
Rajeev40000

Null is not allowed in Emp_ID as it is a Primary key and cannot have a NULL value.

 

Referential Integrity Constraint

  1. Referential Integrity Constraint is specific between two tables.
  2. A foreign key in the 1st table refers to the primary key of the 2nd table, in this case each value of the foreign key in the 1st table has to be null or present in the 2nd table.

Key Constraints

  • The Entity within its entity set is identified uniquely by the key which is the entity set.
  • There can be a number of keys in an entity set but only one will be the primary key out of all keys. In a relational table a primary key can have a unique as well as a null value.

Example

IDNAMESEMESTERAGE
100Naren427
101Lalit628
102Shivanshu322
103Navdeep529
102Karthik725

All row ID must be unique hence 102 is not allowed.

 

Please Share