31 Jan 2020

  • January 31, 2020
  • Amitraj
Relational Integrity Constraints

Every relation has some conditions that must hold for it to be a valid relation. These conditions are called Relational Integrity Constraints. There are three main integrity constraints −

1. Key constraints
2. Domain constraints
3. Referential integrity constraints




1. Key Constraints

There must be at least one minimal subset of attributes in the relation, which can identify a tuple uniquely. This minimal subset of attributes is called key for that relation. If there are more than one such minimal subsets, these are called candidate keys.

Key constraints force that -

-> In a relation with a key attribute, no two tuples can have identical values for key attributes.

-> a key attribute can not have NULL values.

Key constraints are also referred to as Entity Constraints.
The Key attribute should never be NULL or same for two different row of data.




2. Domain Constraint

Domain constraints refers to the rules defined for the values that can be stored for a certain attribute.
                                      or
Attributes have specific values in real-world scenario. 

for example, age cannot be less than zero and telephone numbers cannot contain a digit outside 0-9.




3. Referential Integrity Constraint

Referential integrity constraints work on the concept of Foreign Keys. A foreign key is a key attribute of a relation that can be referred in other relation.

example, if I say Supriya is my girlfriend, then a girl with name Supriya should also exist for that relationship to be present.


If a table reference to some data from another table, then that table and that data should be present for referential integrity constraint to hold true.


Translate

Popular Posts