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

ID NAME SEMESTER AGE
100 Jai 1st 27
101 BKadam 4th 34
102 Rajeev 3rd 31
103 Asmita 6th 29
104 Mahesh 2nd Twenty 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_ID Emp_Name Salary
11 Manish 30000
12 Vikram 20000
13 Sudhir 10000
Rajeev 40000

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

ID NAME SEMESTER AGE
100 Naren 4 27
101 Lalit 6 28
102 Shivanshu 3 22
103 Navdeep 5 29
102 Karthik 7 25

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

 

Please follow and like us:
Content Protection by DMCA.com