FOR FREE CONTENT

Relational constraints or Data Integrity: 

(Important for examination)

 

Relational constraints and data integrity ensure that the data in the database is consistent, accurate, correct, and valid. It ascertains that the data adhere to the set of rules defined by the database administrator and hence, prevent the entry of invalid information into the database. 

 

Here we discuss data integrity as blow: 

i. Domain constraints or Domain integrity

ii. Entity integrity constraints

iii. Key constraints

iv. Referential integrity constraints

v. Semantic integrity constraints

 

(i) Domain Constraint:

Domain integrity constraints can be specified for each attribute by defining its specific range or domain:

a. Every attribute must be atomic

b. The multi-valued attribute is not allowed at the schema

 

 

(ii) Entity Integrity Constraint: 

It ensures that each tuple in a relation is uniquely identified in order to retrieve each tuple separately.

So, no prime attribute has a NULL value i.e. no primary key has a duplicate or NULL value.

 

(iii) Key Constraint:

It ensures that each row in a relation is contained valid data. 

So, two rows have not the same value.

 

 

Particular data can duplicate like two students has the same course but total row not repeated. 

 

(iv) Referential Integrity Constraint:

Referential integrity constraints ensure that the domain for a given attribute D_no, in a relation ‘Employee’ should be the value that appears in a certain attribute say D_no, in a relation ‘Department. Here, D_no of ‘Employee’ is foreign key in the referencing relation ‘Department’ and D_no of Department’ is the primary key of Department’.

 

Referential integrity actually depends on the foreign key.

 

Now, the value of foreign key in the referencing relation must exist in the primary key attribute of the referenced relation or that the foreign key is null value.

 

 

FK is actually the relationship between two tables.

 

(v) Semantic Integrity Constraint

To represent the real-world accurately and consistently, the business rules and logical rules must be enforced on the database. These rules are known as semantic integrity

 

Semantic integrity ensures that the data in the database is logically consistent and complete with respect to the real world.

 

Some examples of Semantic Integrity:

# Number of pages of a book cannot be zero.

# One book can be published by one publisher only.

# Copyright date of a book cannot be later than its published date.

 

Valid State and Invalid State

A database state which does not obey all the integrity constraints is denoted as an Invalid state. On the other hand, a state that contains the values by obeying all the constraints belongs to a valid state.