Lecture 2.3.11
Lecture 2.3.11
(CSE)
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
2
COURSE OUTCOMES
On completion of this course, the students shall be
able to
3
The Problem with NULL
There is a problem with NULL that has persisted since the
Relational
Model was proposed in the 1970’s.
“The simple scientific fact is that an SQL table that contains a null isn’t a relation; thus,
relational theory doesn’t apply, and all bets are off. ” C.Date (2014).
Missing – The information has not been given at the time a row was created. E.g. A
Not Yet – Data is contingent upon an unknown event in the future, E.g. Termination
Does not apply- Is not applicable for this instance of a record . E.g. Hair colour for
bald people,
Number of pregnancies for male patients.
Placeholders – Indicates that we know that a bit of data exists, but we don’t know
Handling NULL in Queries
NULLIF
Syntax: NULLIF (expression, expression)
Returns NULL if both expressions are equal, else returns the first expression.
To compare values we have to use the IS NULL and IS NOT NULL operators in
the
WHERE clause, not the = operator.
IS NULL
SELECT * From Customers WHERE CustName IS NULL
IS NOT NULL
SELECT * From Customers WHERE CustName IS NOT NULL
DQS
To help ensure domain validity and knowledge driven data quality.
Good for data correction, enrichment, standardization, and de-duplication.
May skew the results of data tools that disregard NULL values.
For queries
Email: [email protected]
18