This tutorial highlights the need for applying appropriate table constraints and the different types of constraints.
A database contains many tables. There is a need to define the relationships between the tables. These tables contain a lot of data, sometimes sensitive information. Certain business rules need to be enforced for the smooth functioning of the database machinery. To maintain integrity between values of all tables that are related to each other as well as to enforce certain business rules, some constraints need to be defined and applied to the tables.
Appropriate table constraints are specified on the tables to define the relationship between the tables as well as maintain data integrity.
A constraint is a rule that is used for optimization purposes. Database constraints are rules that define interrelations between tables and can check and modify the data in a database. These rules are realized as special database objects. The main advantage of using constraints consists in capability to implement data check, and a part of business-logic of the application at a level of a database, i.e. to centralize and implify it, so as to make the development of databases applications easier and more reliable.
There are five types of constraints :