BCA / B.Tech 10 min read

Database Constraints

Constraints in DBMS:

Constraints are rules enforced on data columns in a table to ensure the accuracy, reliability, and integrity of the data. They prevent the entry of invalid data into the database.

Types of Constraints:
  • NOT NULL: Ensures that a column cannot have a NULL value.
  • UNIQUE: Ensures that all values in a column are different.
  • PRIMARY KEY: A combination of a NOT NULL and UNIQUE constraint. It uniquely identifies each record in a table. A table can have only one primary key.
  • FOREIGN KEY: Uniquely identifies a row/record in another table. It is used to link two tables together and ensures referential integrity.
  • CHECK: Ensures that all values in a column satisfy a specific condition.
  • DEFAULT: Sets a default value for a column when no value is specified.