DBMS Concepts

DBMS Tutorial Components of DBMS. Applications of DBMS The difference between file system and DBMS. Types of DBMS DBMS Architecture DBMS Schema Three Schema Architecture. DBMS Languages.

DBMS ER Model

ER model: Entity Relationship Diagram (ERD) Components of ER Model. DBMS Generalization, Specialization and Aggregation.

DBMS Relational Model

Codd’s rule of DBMS Relational DBMS concepts Relational Integrity Constraints DBMS keys Convert ER model into Relational model Difference between DBMS and RDBMS Relational Algebra DBMS Joins

DBMS Normalization

Functional Dependency Inference Rules Multivalued Dependency Normalization in DBMS: 1NF, 2NF, 3NF, BCNF and 4NF

DBMS Transaction

What is Transaction? States of transaction ACID Properties in DBMS Concurrent execution and its problems DBMS schedule DBMS Serializability Conflict Serializability View Serializability Deadlock in DBMS Concurrency control Protocols

Difference

Difference between DFD and ERD

Misc

Advantages of DBMS Disadvantages of DBMS Data Models in DBMS Relational Algebra in DBMS Cardinality in DBMS Entity in DBMS Attributes in DBMS Data Independence in DBMS Primary Key in DBMS Foreign Key in DBMS Candidate Key in DBMS Super Key in DBMS Aggregation in DBMS Hashing in DBMS Generalization in DBMS Specialization in DBMS View in DBMS File Organization in DBMS What Is A Cloud Database What Is A Database Levels Of Locking In DBMS What is RDBMS Fragmentation in Distributed DBMS What is Advanced Database Management System Data Abstraction in DBMS Checkpoint In DBMS B Tree in DBMS BCNF in DBMS Advantages of Threaded Binary Tree in DBMS Advantages of Database Management System in DBMS Enforcing Integrity Constraints in DBMS B-Tree Insertion in DBMS B+ Tree in DBMS Advantages of B-Tree in DBMS Types of Data Abstraction in DBMS Levels of Abstraction in DBMS 3- Tier Architecture in DBMS Anomalies in Database Management System Atomicity in Database Management System Characteristics of DBMS DBMS Examples Difference between Relational and Non-Relational Databases Domain Constraints in DBMS Entity and Entity set in DBMS ER Diagram for Banking System in DBMS ER Diagram for Company Database in DBMS ER Diagram for School Management System in DBMS ER Diagram for Student Management System in DBMS ER Diagram for University Database in DBMS ER Diagram of Company Database in DBMS Er Diagram Symbols and Notations in DBMS How to draw ER-Diagram in DBMS Integrity Constraints in DBMS Red-Black Tree Deletion in DBMS Red-Black Tree Properties in DBMS Red-Black Tree Visualization in DBMS Redundancy in Database Management System Secondary Key in DBMS Structure of DBMS 2-Tier Architecture in DBMS Advantages and Disadvantages of Binary Search Tree Closure of Functional Dependency in DBMS Consistency in Database Management System Durability in Database Management System ER Diagram for Bank Management System in DBMS ER Diagram for College Management System in DBMS ER Diagram for Hotel Management System in DBMS ER Diagram for Online Shopping ER Diagram for Railway Reservation System ER Diagram for Student Management System in DBMS Isolation in DBMS Lossless Join and Dependency Preserving Decomposition in DBMS Non-Key Attributes in DBMS Data Security Requirements in DBMS DBMS functions and Components What is Homogeneous Database? DBMS Functions and Components Advantages and Disadvantages of Distributed Database Relational Database Schema in DBMS Relational Schema Transaction Processing in DBMS Discriminator in DBMS

Domain Constraints in DBMS

Introduction about DBMS:-

DBMS stands for DataBase Management System. DBMS(DataBase Management System) is a type of software by which we can save and retrieve the user's data with the security process. DBMS can manipulate the database with the help of a group of programs. The DBMS(DataBase Management System) can accept the request from the operating system to supply the data. The DBMS also can accept the request to retrieve a large amount of data through the user and third-party software. DBMS(DataBase Management System) also give permission to the user to use the data according to their needs. The word "DBMS" contains information regarding the database program and the users. It also provides an interface between the user and the software. In this topic, we are going to discuss the various type of DBMS.

In DBMS(DataBase Management System), there are four types of constraints available. These are as follows.

  1. Domain constraint.
  2. Entity integrity constraint.
  3. Referential Integrity constraints.
  4. Key constraints.

In this article, we are going to know about only domain constraints. Let's discuss that. 

Domain constraint:-

Domain constraints are a type of user-defined column that helps us to arrange the data we have entered according to the datatype. If we enter a wrong value according to the datatype, then the domain constraint provides an error alert to the user that the column is not fulfilled properly. In another way, we can say that domain constraint is a type of attribute which specify all the possible value that the attributes can hold properly. The attributes that can be held by the values are time, integer, date, character, string, etc. it also defines the set of values for the attributes. And the attribute also ensures that the value taken by the attributes must have the atomic value. Here atomic value means the value cannot be divided from its domain. 

Syntax for domain constraint :

The syntax for domain constraint is as below.

Domain Constraint = data type(integer / character/date / time / string / etc.) + 
                    Constraints(NOT NULL / UNIQUE / PRIMARY KEY / 
                                FOREIGN KEY / CHECK / DEFAULT)

Types of Domain Constraint:-

The domain constraint is further divided into two types. These are as follows. 

  1. Domain Constraints – Not Null
  2. Domain Constraints – Check

1, Domain Constraint-Not Null:-

Here the null value means the value is not assigned with any attributes. We can also say that the null value is the value of the unknown or missing attribute, and the null values are held by the column. But the column has a feature that does not accept any null value, which means that the column must have to be contained some attribute value.  

Example: In the employee database, every employee must have a name associated with them.

Create table employee
(employee_id varchar(45),
employee_name varchar(45) not null,
salary NUMBER);

output:-

Domain Constraints in DBMS

2. Domain Constraints – Check: It defines a condition that each row must satisfy, which means it restricts the value of a column between ranges, or we can say that it is just like a condition or filter checking before saving data into a column. It ensures that when a tuple is inserted inside, the relation must satisfy the predicate given in the check clause.

Example: We need to check whether the entered id number is greater than 0 for the employee table.

Create table employee
(employee_id varchar(45) not null check(employee_id > 0),
employee_name varchar(45),
salary NUMBER);

output:

Domain Constraints in DBMS

The above example creates CHECK constraints on the employee_id column and specifies that the column employee_id must only include integers greater than 0.

Note: In DBMS, a table is a combination of rows and columns in which we have some unique attribute names associated with it. And basically, a domain is a unique set of values present in a table. Let's take an example; suppose we have a table student which consists of 3 attributes NAME, ROLL NO, and MARKS. Now ROLL NO attributes can only have numbers associated with them and won't contain any alphabet. So we can say that it contains only the domain of an integer, and it can be only a positive number greater than 0.

Conclusion

  • In a database, a domain is a set of values that can be assigned to an attribute.
  • A domain can be created using the CREATE DOMAIN command in SQL.
  • There are two types of domain constraints, NOT NULL and CHECK.