In this video, we have covered what are constraints in DBMS & the types of constraints in DBMS.
Constraints in databases are mainly categorised into three categories, i.e.
1) Implicit constraints: These database constraints are applied on the data model.
2) Explicit constraints: Explicit constraints are directly applied to the schemas o the data model, these constraints can be specified in the DDL(Data Definition language).
3) Application-based or semantic constraints: Application-based constraints cannot be applied to schemas directly.
There are five different types of implicit constraints in the database, which are as follows:
1) Domain Constraint
2) Uniqueness of tuple constraints
3) Key constraint
4) Entity integrity constraints
5) Referential integrity constraints
1) Domain constraint specifies the group of possible values that an attribute can hold like integer, character, date, time, string, etc. The main purpose of this constraint is to help users to enter the value according to the data type. Domain constraint is applicable to user-defined columns.
2) Uniqueness of tuple constraint is a constraint that provides a unique value to each tuple(row) in a given relation. In simple words, this means two rows in a table could not be the same. Its sole purpose is to provide unique value to each row, in order to ease the data retrieval process and this also reduces redundancy in the database.
3) Key constraint is as conditions that make it possible to identify each tuple uniquely for a given relation. Its main purpose is to identify each tuple uniquely, this is done in two ways values of the primary key must not be duplicated and values of the primary key must not be null.
4) Entity Key Constraint enforces no null value in a primary key attribute because a null value in the primary key breaches the uniqueness constraint.
5) Referential Key Constraint maintains the consistency among the tuples in two relations. It is imposed through a foreign key when the domain of an attribute in the foreign key of relation R1 is the same as that of the primary key of relation R2. It should be noted that we can't insert a value into a referencing relation if that value does not exist in the referenced relation. Also, we can't delete or update a value of the referenced relation if the corresponding record exists in the referencing relation.
Constraints on Relational Database Model: https://www.geeksforgeeks.org/constraints-on-relational-database-model/