What is Constraints?
Constraints are the rules enforced on data columns on table. These are used to limit the types of data that can go into the table. This ensures the accuracy and reliability of the data in the database. Constraint could be applied at column level or table level. Column level constraints are applied only one column whereas table level constraints are applied to the whole table.
Conceptually, data constraints are connected to column as flag, whenever; an attempt is made to load the column with data, the DB engine observes the flag and recognizes the presence of a constraints.
There are two types of data constraints that can be applied to data being inserted into the tables
This data constraint determines the speed at which data can be inserted or extracted from a table. Following is the types of I/O Constraints:
A. PRIMARY KEY B. FOREIGN KEY (REFERENCE KEY) C. UNIQUE
Business Rule Constraints:
Business Rule constraints allows application of business rues to table columns, they vary from system to system. These rules are applied to data, prior the data is being inserted into the table columns. This ensures that the data in the table have integrity. Following is the types of Business Rule Constraints:
D. NOT NULL E. CHECK CONSTRAINT F. DEFAULT VALUE
Below figure shows the hierarchy of Data Integrity Constraints.