SlideShare a Scribd company logo
Domains
Understanding Domain Integrity
Version 1.0
(c) Rushdi Shams, CSE@KUET 1
What are Domains
 Domains are pools of values from where
values appear in the column of a table
 Domain of a column is KIND of value it
can represent
 Column: domain- it defines the kind of
values the column represents
 Data type and domain are two different
things
 Data type is a physical thing while
domain is a logical thing
(c) Rushdi Shams, CSE@KUET 2
What are domains (continued)
 I said, domain is a all possible collection of
values that a column can contain, in this
example, you have one perspective why I said
so!
 Say, Staffno column has 4 values in it-
01K28, 01B23, 03X98 and 09Y12 (well, I can’t
say what they really mean)! The domain of
Staffno is {01K28, 01B23, 03X98 and 09Y12}.
3(c) Rushdi Shams, CSE@KUET
What are domains (continued)
 I also said that domain represents the
kind of data it represents. The following
example will simplify the statement
 Say, Streetname and Studentname are
two columns of a table. They can both
have the same data type like TEXT or
CHAR or VARCHAR or whatever…can’t
they? But they are different. Aren’t they?
(c) Rushdi Shams, CSE@KUET 4
What are domains (continued)
 Again, say, there are two columns in a
table named rollnumber and salary having
the same data type INTEGER, NUMBER or
whatever…but they are different, no?
 So, studentname and streetname have
different domains and rollnumber and
salary have different domains
 In these two example, you can see the
difference between data type and domain
as well. Can’t you?
(c) Rushdi Shams, CSE@KUET 5
What are domains (continued)
 Doamins are thus narrower concept than
data types. What is a narrower concept?
Well it means, it is descriptive!
Degreeawarded column can be
represented by simply datatype TEXT (3).
But in domains, it is represented by
{BA, BS, MA, MS, PhD, LLD, MD}
 But remember one thing- you don’t
manipulate domains in database
engine, you work with data type (as data
type is physical and domain is logical thing)
(c) Rushdi Shams, CSE@KUET 6
What are domains (continued)
 Sometimes domains are large in
numbers so that they become difficult to
implement. Say, AGE! What if you are
representing the domain AGE? You can
then use the concept of range. The
domain of AGE can be between 1 to
120.
(c) Rushdi Shams, CSE@KUET 7
Deep into domains
 Now, we will dig into deep of the domain
and data type concept
 Sometimes, you will need to compare
between columns of two tables.
Then, you will need the concept of
domain.
(c) Rushdi Shams, CSE@KUET 8
Deep into domains (continued)
 SALES table has
Salesperson ID which is
eventually the Employee
ID of EMPLOYEE table.
 So, Mr. Michael Suyama
was dealing with Order
ID 10643.
 You may have to
compare them to find out
this information.
 If the domain of
Salesperson ID and
Employee ID is not
same, you could not
compare them!
9(c) Rushdi Shams, CSE@KUET
Deep into domains (continued)
 So, Salesperson ID and Employee ID,
as they are comparable, are called type-
compatible
 Trying to combine the relations on
Employee ID and Order ID, however,
would probably not result in a
meaningful answer, even if the two
domains were defined on the same data
type.
(c) Rushdi Shams, CSE@KUET 10
Domain Integrity
 In a database the domain integrity is
defined by
1. Data type and length
2. NULL value acceptance
3. Allowable values through rules
4. Default value
Back 1
Back 2
(c) Rushdi Shams, CSE@KUET 11
Domain Constraints
 Domain constraints are rules that define legal
values for columns
 Sometimes more than one rule is needed for a
column to completely define the legal values
 Unfortunately, SQL and other database engine
generally don’t facilitate with powerful tools to
recognize violations on domains.
 If employee ID and Salary are both NUMBERs
then, if you make a query by relating them, they
will certainly give you an answer! Aweful, huh?
 But some tools can still be easily manipulated to
avoid the violations.
(c) Rushdi Shams, CSE@KUET 12
Domain Constraints (continued)
DEFAULT
 You can use DEFAULT to set a column value to
some specific value. In this example, the data type
and length, NULL value acceptance and default
value is covered (see Domain Integrity)
CREATE TABLE Course(
Course_ID NUMBER(10) NOT NULL,
Course_Name VARCHAR(20),
Pass_Mark INTEGER(3) DEFAULT 40,
PRIMARY KEY (Course_ID)
);
(c) Rushdi Shams, CSE@KUET 13
Domain Constraints (continued)
CHECK
 This is a good tool to check if violation in putting data have
occurred or not. In this example NULL value
acceptance, data types and length and the allowable value
by rules are covered (see Domain Integrity)
CREATE TABLE Subject(
Subject_ID VARCHAR(10) NOT NULL,
Subject_Name VARCHAR(20),
Credit NUMBER(10)
CHECK(Credit>0 AND Credit<=10),
PRIMARY KEY (Subject_ID)
);
(c) Rushdi Shams, CSE@KUET 14
Domain Constraints (continued)
 If you use CHECK on more than one
column in a table, that constraint is also
called table constraint.
CREATE TABLE Lecturer(
ID VARCHAR(10) NOT NULL,
Name VARCHAR(20),
Grade CHAR(1),
Salary INTEGER(5),
CHECK (Salary<50000 OR Grade<=‘B’),
PRIMARY KEY (ID)
);
(c) Rushdi Shams, CSE@KUET 15
References
 Designing Effective Database Systems
by Rebecca M. Riordan, Addison
Wesley Professional, 2005
 Structured Query Language: A Practical
Introduction by Akil I Din
 Database Systems by Paul Beynon-
Devies, Palgrave Macmillan, 2004
 www.databasedev.co.uk
(c) Rushdi Shams, CSE@KUET 16

More Related Content

PPT
JAVA Programming notes.ppt
DOCX
CADBURY-GEMS
PPTX
Pass by value and pass by reference
PDF
ZONAL MAP OF INDIA
PPTX
Pointer in c
DOCX
Parle G Report
PPTX
PPTX
Study Project - The Relation Between Video Games And People's Heart Rates and...
JAVA Programming notes.ppt
CADBURY-GEMS
Pass by value and pass by reference
ZONAL MAP OF INDIA
Pointer in c
Parle G Report
Study Project - The Relation Between Video Games And People's Heart Rates and...

What's hot (20)

PPTX
Presentation On Haldiram
PPTX
Big basket
PPTX
Pantaloon revolutionising inventory management in indian retailing
PPTX
BASIC Programming Language
PPTX
USER DEFINE FUNCTIONS IN PYTHON
DOCX
Preface
PPTX
Tcs ppt
PPTX
PDF
#63 Dr B.V. MEHTA Paper Presentation on "Demand and Supply of Edible Oils in ...
DOCX
CREAM BELL PROJECT BY RAHUL SINGH
PPTX
String Library Functions
PPTX
Cadbury presentation
PPTX
Indian farmer presentation
PPT
PPTX
Pantaloonprojectppt 131011061002-phpapp02
PPTX
Kissan ketchup brand extension analysis
PPTX
Nirma final ppt
PPTX
DATATYPES,KEYWORDS,FORMATSPECS[1].pptx
PPT
Woodland Shoes 7 P's and Product Life Cycle
Presentation On Haldiram
Big basket
Pantaloon revolutionising inventory management in indian retailing
BASIC Programming Language
USER DEFINE FUNCTIONS IN PYTHON
Preface
Tcs ppt
#63 Dr B.V. MEHTA Paper Presentation on "Demand and Supply of Edible Oils in ...
CREAM BELL PROJECT BY RAHUL SINGH
String Library Functions
Cadbury presentation
Indian farmer presentation
Pantaloonprojectppt 131011061002-phpapp02
Kissan ketchup brand extension analysis
Nirma final ppt
DATATYPES,KEYWORDS,FORMATSPECS[1].pptx
Woodland Shoes 7 P's and Product Life Cycle
Ad

Viewers also liked (14)

PPT
Transefermation
PPTX
Measuring What Matters: Meaningful Metrics
PPTX
A reference architecture for the internet of things
PDF
A Reference Architecture for IoT
PDF
What exactly is the "Internet of Things"?
PDF
The 2016 CES Report: The Trend Behind the Trend
PPTX
The 10 Most Important Banking Metrics
PDF
IoT architecture
PPTX
Design Thinking is Killing Creativity
PPTX
The Creative Classroom
PPT
Internet of Things and its applications
PDF
10 Things Money Can´t Buy
PDF
Internet of Things
PDF
UX, ethnography and possibilities: for Libraries, Museums and Archives
Transefermation
Measuring What Matters: Meaningful Metrics
A reference architecture for the internet of things
A Reference Architecture for IoT
What exactly is the "Internet of Things"?
The 2016 CES Report: The Trend Behind the Trend
The 10 Most Important Banking Metrics
IoT architecture
Design Thinking is Killing Creativity
The Creative Classroom
Internet of Things and its applications
10 Things Money Can´t Buy
Internet of Things
UX, ethnography and possibilities: for Libraries, Museums and Archives
Ad

Similar to L4 domain integrity (20)

PPT
PPT
Database Tables and Data Types
PPT
Physical elements of data
PDF
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
PPTX
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
PDF
DBMS MODULE 3 NOTES ENGINEERING CSE .pdf
PPTX
MSAvMySQL.pptx
PDF
4.Database Management System.pdf
PDF
PT- Oracle session01
PDF
Sql ch 4
PPTX
Quick Revision on DATA BASE MANAGEMENT SYSTEMS concepts.pptx
DOCX
Database Management Lab -SQL Queries
PDF
Chapter 4 Structured Query Language
PDF
SQL cheat sheet.pdf
PDF
PPT
Dbms ii mca-ch4-relational model-2013
DOCX
DATABASE MANAGEMENT SYSTEM
DOCX
CSCI 2215 — Databases — Fall 2015HW 1, Due Friday, 092515.docx
Database Tables and Data Types
Physical elements of data
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
DBMS MODULE 3 NOTES ENGINEERING CSE .pdf
MSAvMySQL.pptx
4.Database Management System.pdf
PT- Oracle session01
Sql ch 4
Quick Revision on DATA BASE MANAGEMENT SYSTEMS concepts.pptx
Database Management Lab -SQL Queries
Chapter 4 Structured Query Language
SQL cheat sheet.pdf
Dbms ii mca-ch4-relational model-2013
DATABASE MANAGEMENT SYSTEM
CSCI 2215 — Databases — Fall 2015HW 1, Due Friday, 092515.docx

More from Rushdi Shams (20)

PDF
Research Methodology and Tips on Better Research
PPTX
Common evaluation measures in NLP and IR
PPTX
Machine learning with nlp 101
PPTX
Semi-supervised classification for natural language processing
PPTX
Natural Language Processing: Parsing
PPT
Types of machine translation
PDF
L1 l2 l3 introduction to machine translation
PPT
Syntax and semantics
PPTX
Propositional logic
PPTX
Probabilistic logic
PPT
L15 fuzzy logic
PPT
Knowledge structure
PPT
Knowledge representation
PPT
First order logic
PPTX
Belief function
PPT
L5 understanding hacking
PPT
L4 vpn
PPT
L3 defense
PPT
L2 Intrusion Detection System (IDS)
PPT
L1 phishing
Research Methodology and Tips on Better Research
Common evaluation measures in NLP and IR
Machine learning with nlp 101
Semi-supervised classification for natural language processing
Natural Language Processing: Parsing
Types of machine translation
L1 l2 l3 introduction to machine translation
Syntax and semantics
Propositional logic
Probabilistic logic
L15 fuzzy logic
Knowledge structure
Knowledge representation
First order logic
Belief function
L5 understanding hacking
L4 vpn
L3 defense
L2 Intrusion Detection System (IDS)
L1 phishing

Recently uploaded (20)

PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
The various Industrial Revolutions .pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Hybrid model detection and classification of lung cancer
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
observCloud-Native Containerability and monitoring.pptx
PPT
What is a Computer? Input Devices /output devices
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Getting started with AI Agents and Multi-Agent Systems
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Assigned Numbers - 2025 - Bluetooth® Document
The various Industrial Revolutions .pptx
Zenith AI: Advanced Artificial Intelligence
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative study of natural language inference in Swahili using monolingua...
Hybrid model detection and classification of lung cancer
Web App vs Mobile App What Should You Build First.pdf
O2C Customer Invoices to Receipt V15A.pptx
Chapter 5: Probability Theory and Statistics
1 - Historical Antecedents, Social Consideration.pdf
Final SEM Unit 1 for mit wpu at pune .pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
observCloud-Native Containerability and monitoring.pptx
What is a Computer? Input Devices /output devices
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game

L4 domain integrity

  • 1. Domains Understanding Domain Integrity Version 1.0 (c) Rushdi Shams, CSE@KUET 1
  • 2. What are Domains  Domains are pools of values from where values appear in the column of a table  Domain of a column is KIND of value it can represent  Column: domain- it defines the kind of values the column represents  Data type and domain are two different things  Data type is a physical thing while domain is a logical thing (c) Rushdi Shams, CSE@KUET 2
  • 3. What are domains (continued)  I said, domain is a all possible collection of values that a column can contain, in this example, you have one perspective why I said so!  Say, Staffno column has 4 values in it- 01K28, 01B23, 03X98 and 09Y12 (well, I can’t say what they really mean)! The domain of Staffno is {01K28, 01B23, 03X98 and 09Y12}. 3(c) Rushdi Shams, CSE@KUET
  • 4. What are domains (continued)  I also said that domain represents the kind of data it represents. The following example will simplify the statement  Say, Streetname and Studentname are two columns of a table. They can both have the same data type like TEXT or CHAR or VARCHAR or whatever…can’t they? But they are different. Aren’t they? (c) Rushdi Shams, CSE@KUET 4
  • 5. What are domains (continued)  Again, say, there are two columns in a table named rollnumber and salary having the same data type INTEGER, NUMBER or whatever…but they are different, no?  So, studentname and streetname have different domains and rollnumber and salary have different domains  In these two example, you can see the difference between data type and domain as well. Can’t you? (c) Rushdi Shams, CSE@KUET 5
  • 6. What are domains (continued)  Doamins are thus narrower concept than data types. What is a narrower concept? Well it means, it is descriptive! Degreeawarded column can be represented by simply datatype TEXT (3). But in domains, it is represented by {BA, BS, MA, MS, PhD, LLD, MD}  But remember one thing- you don’t manipulate domains in database engine, you work with data type (as data type is physical and domain is logical thing) (c) Rushdi Shams, CSE@KUET 6
  • 7. What are domains (continued)  Sometimes domains are large in numbers so that they become difficult to implement. Say, AGE! What if you are representing the domain AGE? You can then use the concept of range. The domain of AGE can be between 1 to 120. (c) Rushdi Shams, CSE@KUET 7
  • 8. Deep into domains  Now, we will dig into deep of the domain and data type concept  Sometimes, you will need to compare between columns of two tables. Then, you will need the concept of domain. (c) Rushdi Shams, CSE@KUET 8
  • 9. Deep into domains (continued)  SALES table has Salesperson ID which is eventually the Employee ID of EMPLOYEE table.  So, Mr. Michael Suyama was dealing with Order ID 10643.  You may have to compare them to find out this information.  If the domain of Salesperson ID and Employee ID is not same, you could not compare them! 9(c) Rushdi Shams, CSE@KUET
  • 10. Deep into domains (continued)  So, Salesperson ID and Employee ID, as they are comparable, are called type- compatible  Trying to combine the relations on Employee ID and Order ID, however, would probably not result in a meaningful answer, even if the two domains were defined on the same data type. (c) Rushdi Shams, CSE@KUET 10
  • 11. Domain Integrity  In a database the domain integrity is defined by 1. Data type and length 2. NULL value acceptance 3. Allowable values through rules 4. Default value Back 1 Back 2 (c) Rushdi Shams, CSE@KUET 11
  • 12. Domain Constraints  Domain constraints are rules that define legal values for columns  Sometimes more than one rule is needed for a column to completely define the legal values  Unfortunately, SQL and other database engine generally don’t facilitate with powerful tools to recognize violations on domains.  If employee ID and Salary are both NUMBERs then, if you make a query by relating them, they will certainly give you an answer! Aweful, huh?  But some tools can still be easily manipulated to avoid the violations. (c) Rushdi Shams, CSE@KUET 12
  • 13. Domain Constraints (continued) DEFAULT  You can use DEFAULT to set a column value to some specific value. In this example, the data type and length, NULL value acceptance and default value is covered (see Domain Integrity) CREATE TABLE Course( Course_ID NUMBER(10) NOT NULL, Course_Name VARCHAR(20), Pass_Mark INTEGER(3) DEFAULT 40, PRIMARY KEY (Course_ID) ); (c) Rushdi Shams, CSE@KUET 13
  • 14. Domain Constraints (continued) CHECK  This is a good tool to check if violation in putting data have occurred or not. In this example NULL value acceptance, data types and length and the allowable value by rules are covered (see Domain Integrity) CREATE TABLE Subject( Subject_ID VARCHAR(10) NOT NULL, Subject_Name VARCHAR(20), Credit NUMBER(10) CHECK(Credit>0 AND Credit<=10), PRIMARY KEY (Subject_ID) ); (c) Rushdi Shams, CSE@KUET 14
  • 15. Domain Constraints (continued)  If you use CHECK on more than one column in a table, that constraint is also called table constraint. CREATE TABLE Lecturer( ID VARCHAR(10) NOT NULL, Name VARCHAR(20), Grade CHAR(1), Salary INTEGER(5), CHECK (Salary<50000 OR Grade<=‘B’), PRIMARY KEY (ID) ); (c) Rushdi Shams, CSE@KUET 15
  • 16. References  Designing Effective Database Systems by Rebecca M. Riordan, Addison Wesley Professional, 2005  Structured Query Language: A Practical Introduction by Akil I Din  Database Systems by Paul Beynon- Devies, Palgrave Macmillan, 2004  www.databasedev.co.uk (c) Rushdi Shams, CSE@KUET 16