Domain in DBMS

Learn via video course
FREE
View all courses
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
Topics Covered

The data type defined for a column in a database is called a database domain. This data type can either be a built-in type (such as an integer or a string) or a custom type that defines data constraints.

To understand this more effectively, let's think like this:
A database schema has a set of attributes, also called columns or fields, that define the database. Each attribute has a domain that specifies the types of values that can be used, as well as other information such as data type, length, and values.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Creating a Domain

To create a domain, we use the CREATE DOMAIN command in SQL.

Let's look at the syntax:

The above statement, for example, creates a C_Number attribute with ten integers to store contact numbers. It's not possible to use a NULL or an unknown value. This generates a ten-integer C_Number property, in which it wouldn't be possible to use a NULL or an unknown value.

Domain Integrity Constraints

Domain Constraints are user-defined columns that assist the user in entering values that are appropriate for the data type. If it detects an incorrect input, it informs the user that the column is not properly filled. Or, to put it another way, it's an attribute that describes all of the potential values for the attribute, such as integer, character, date, time, string, and so on.

To read more about domain integrity constraints, please head over to our dedicated article here!

Types of Domain Constraints

There are two types of domain constraints:

  1. NOT NULL:
    The Not Null constraint prevents a column from accepting null values. This implies that you can't create a new record or change an existing one without first putting a value in the field.

    Example:

  2. Check:
    It restricts the value of a column across ranges. It can also be understood as it's like a condition or filter checking before saving data into a column since it defines a condition that each row must satisfy.

    Example:

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.
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more