Domain Constraints in DBMS
Domain constraints in DBMS
In this article, we will learn about Domain Constraints in DBMS.
- DBMS table is viewed as a combination of rows and columns.
- For example, if you are having a column called month and you want only [Jan, Feb, March….dec] as values allowed to be entered for that particular column which is referred to as domain for that particular column that.
Domain constraint ensures two things
- It makes sure that the data value entered for that particular column matches with the data type defined for that column
- It shows that the constraints((NOT NULL / UNIQUE / PRIMARY KEY / FOREIGN KEY / CHECK / DEFAULT)) impose on that column not fulfilled or not
Domain Constraint = data type check for the column + Constraints (NOT NULL / UNIQUE / PRIMARY KEY / FOREIGN KEY / CHECK / DEFAULT)
For example, we want to create a table “student” with “stu_id” field having a value greater than 100, can create a domain and table like this:
create domain id_value int
check(value > 100);
create table student (
stu_id id_value PRIMARY KEY,