<s>
In	O
SQL	B-Language
,	O
null	O
or	O
NULL	O
is	O
a	O
special	O
marker	O
used	O
to	O
indicate	O
that	O
a	O
data	O
value	O
does	O
not	O
exist	O
in	O
the	O
database	O
.	O
</s>
<s>
Introduced	O
by	O
the	O
creator	O
of	O
the	O
relational	B-Architecture
database	I-Architecture
model	I-Architecture
,	O
E	O
.	O
F	O
.	O
Codd	O
,	O
SQL	B-Language
null	O
serves	O
to	O
fulfil	O
the	O
requirement	O
that	O
all	O
true	O
relational	B-Architecture
database	O
management	O
systems	O
(	O
RDBMS	O
)	O
support	O
a	O
representation	O
of	O
"	O
missing	O
information	O
and	O
inapplicable	O
information	O
"	O
.	O
</s>
<s>
Codd	O
also	O
introduced	O
the	O
use	O
of	O
the	O
lowercase	O
Greek	O
omega	B-General_Concept
( ω	O
)	O
symbol	O
to	O
represent	O
null	O
in	O
database	B-General_Concept
theory	I-General_Concept
.	O
</s>
<s>
In	O
SQL	B-Language
,	O
NULL	O
is	O
a	O
reserved	B-Language
word	I-Language
used	O
to	O
identify	O
this	O
marker	O
.	O
</s>
<s>
In	O
a	O
database	O
table	O
,	O
the	O
column	B-Application
reporting	O
this	O
answer	O
would	O
start	O
out	O
with	O
no	O
value	O
(	O
marked	O
by	O
Null	O
)	O
,	O
and	O
it	O
would	O
not	O
be	O
updated	O
with	O
the	O
value	O
"	O
zero	O
"	O
until	O
we	O
have	O
ascertained	O
that	O
Adam	O
owns	O
no	O
books	O
.	O
</s>
<s>
SQL	B-Language
null	O
is	O
a	O
marker	O
,	O
not	O
a	O
value	O
.	O
</s>
<s>
This	O
usage	O
is	O
quite	O
different	O
from	O
most	O
programming	O
languages	O
,	O
where	B-Language
null	O
value	O
of	O
a	O
reference	O
means	O
it	O
is	O
not	O
pointing	O
to	O
any	O
object	O
.	O
</s>
<s>
E	O
.	O
F	O
.	O
Codd	O
mentioned	O
nulls	O
as	O
a	O
method	O
of	O
representing	O
missing	O
data	O
in	O
the	O
relational	B-Architecture
model	I-Architecture
in	O
a	O
1975	O
paper	O
in	O
the	O
FDT	O
Bulletin	O
of	O
ACM-SIGMOD	O
.	O
</s>
<s>
Codd	O
's	O
paper	O
that	O
is	O
most	O
commonly	O
cited	O
in	O
relation	O
with	O
the	O
semantics	O
of	O
Null	O
(	O
as	O
adopted	O
in	O
SQL	B-Language
)	O
is	O
his	O
1979	O
paper	O
in	O
the	O
ACM	O
Transactions	O
on	O
Database	O
Systems	O
,	O
in	O
which	O
he	O
also	O
introduced	O
his	O
Relational	B-Application
Model/Tasmania	I-Application
,	O
although	O
much	O
of	O
the	O
other	O
proposals	O
from	O
the	O
latter	O
paper	O
have	O
remained	O
obscure	O
.	O
</s>
<s>
In	O
database	B-General_Concept
theory	I-General_Concept
circles	O
,	O
the	O
original	O
proposal	O
of	O
Codd	O
(	O
1975	O
,	O
1979	O
)	O
is	O
now	O
referred	O
to	O
as	O
"	O
Codd	O
tables	O
"	O
.	O
</s>
<s>
The	O
1986	O
SQL	B-Language
standard	O
basically	O
adopted	O
Codd	O
's	O
proposal	O
after	O
an	O
implementation	O
prototype	O
in	O
IBM	B-Application
System	I-Application
R	I-Application
.	O
Although	O
Don	O
Chamberlin	O
recognized	O
nulls	O
(	O
alongside	O
duplicate	O
rows	O
)	O
as	O
one	O
of	O
the	O
most	O
controversial	O
features	O
of	O
SQL	B-Language
,	O
he	O
defended	O
the	O
design	O
of	O
Nulls	O
in	O
SQL	B-Language
invoking	O
the	O
pragmatic	O
arguments	O
that	O
it	O
was	O
the	O
least	O
expensive	O
form	O
of	O
system	O
support	O
for	O
missing	O
information	O
,	O
saving	O
the	O
programmer	O
from	O
many	O
duplicative	O
application-level	O
checks	O
(	O
see	O
semipredicate	O
problem	O
)	O
while	O
at	O
the	O
same	O
time	O
providing	O
the	O
database	O
designer	O
with	O
the	O
option	O
not	O
to	O
use	O
Nulls	O
if	B-Language
they	O
so	O
desire	O
;	O
for	O
example	O
,	O
in	O
order	O
to	O
avoid	O
well	O
known	O
anomalies	O
(	O
discussed	O
in	O
the	O
semantics	O
section	O
of	O
this	O
article	O
)	O
.	O
</s>
<s>
Chamberlin	O
also	O
argued	O
that	O
besides	O
providing	O
some	O
missing-value	O
functionality	O
,	O
practical	O
experience	O
with	O
Nulls	O
also	O
led	O
to	O
other	O
language	O
features	O
which	O
rely	O
on	O
Nulls	O
,	O
like	O
certain	O
grouping	O
constructs	O
and	O
outer	B-Language
joins	I-Language
.	O
</s>
<s>
Finally	O
,	O
he	O
argued	O
that	O
in	O
practice	O
Nulls	O
also	O
end	O
up	O
being	O
used	O
as	O
a	O
quick	O
way	O
to	O
patch	O
an	O
existing	O
schema	B-Application
when	O
it	O
needs	O
to	O
evolve	O
beyond	O
its	O
original	O
intent	O
,	O
coding	O
not	O
for	O
missing	O
but	O
rather	O
for	O
inapplicable	O
information	O
;	O
for	O
example	O
,	O
a	O
database	O
that	O
quickly	O
needs	O
to	O
support	O
electric	O
cars	O
while	O
having	O
a	O
miles-per-gallon	O
column	B-Application
.	O
</s>
<s>
Codd	O
indicated	O
in	O
his	O
1990	O
book	O
The	O
Relational	B-Architecture
Model	I-Architecture
for	O
Database	O
Management	O
,	O
Version	O
2	O
that	O
the	O
single	O
Null	O
mandated	O
by	O
the	O
SQL	B-Language
standard	O
was	O
inadequate	O
,	O
and	O
should	O
be	O
replaced	O
by	O
two	O
separate	O
Null-type	O
markers	O
to	O
indicate	O
the	O
reason	O
why	O
data	O
is	O
missing	O
.	O
</s>
<s>
Codd	O
's	O
recommendation	O
would	O
have	O
required	O
SQL	B-Language
's	O
logic	O
system	O
be	O
expanded	O
to	O
accommodate	O
a	O
four-valued	O
logic	O
system	O
.	O
</s>
<s>
Null	O
has	O
been	O
the	O
focus	O
of	O
controversy	O
and	O
a	O
source	O
of	O
debate	O
because	O
of	O
its	O
associated	O
three-valued	B-Language
logic	I-Language
(	O
3VL	B-Language
)	O
,	O
special	O
requirements	O
for	O
its	O
use	O
in	O
SQL	B-Language
joins	I-Language
,	O
and	O
the	O
special	O
handling	O
required	O
by	O
aggregate	O
functions	O
and	O
SQL	B-Language
grouping	O
operators	O
.	O
</s>
<s>
Computer	O
science	O
professor	O
Ron	O
van	O
der	O
Meyden	O
summarized	O
the	O
various	O
issues	O
as	O
:	O
"	O
The	O
inconsistencies	O
in	O
the	O
SQL	B-Language
standard	O
mean	O
that	O
it	O
is	O
not	O
possible	O
to	O
ascribe	O
any	O
intuitive	O
logical	O
semantics	O
to	O
the	O
treatment	O
of	O
nulls	O
in	O
SQL.	O
"	O
</s>
<s>
Though	O
this	O
behavior	O
is	O
not	O
defined	O
by	O
the	O
ISO	O
SQL	B-Language
standard	O
many	O
DBMS	O
vendors	O
treat	O
this	O
operation	O
similarly	O
.	O
</s>
<s>
For	O
instance	O
,	O
the	O
Oracle	O
,	O
PostgreSQL	B-Application
,	O
MySQL	B-Application
Server	I-Application
,	O
and	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
platforms	O
all	O
return	O
a	O
Null	O
result	O
for	O
the	O
following	O
:	O
</s>
<s>
String	O
concatenation	O
operations	O
,	O
which	O
are	O
common	O
in	O
SQL	B-Language
,	O
also	O
result	O
in	O
Null	O
when	O
one	O
of	O
the	O
operands	O
is	O
Null	O
.	O
</s>
<s>
The	O
following	O
example	O
demonstrates	O
the	O
Null	O
result	O
returned	O
by	O
using	O
Null	O
with	O
the	O
SQL	B-Language
||	O
string	O
concatenation	O
operator	O
.	O
</s>
<s>
Since	O
Null	O
is	O
not	O
a	O
member	O
of	O
any	O
data	B-Application
domain	I-Application
,	O
it	O
is	O
not	O
considered	O
a	O
"	O
value	O
"	O
,	O
but	O
rather	O
a	O
marker	O
(	O
or	O
placeholder	O
)	O
indicating	O
the	O
undefined	B-General_Concept
value	I-General_Concept
.	O
</s>
<s>
However	O
,	O
certain	O
operations	O
on	O
Null	O
can	O
return	O
values	O
if	B-Language
the	O
absent	O
value	O
is	O
not	O
relevant	O
to	O
the	O
outcome	O
of	O
the	O
operation	O
.	O
</s>
<s>
SQL	B-Language
implements	O
three	O
logical	O
results	O
,	O
so	O
SQL	B-Language
implementations	O
must	O
provide	O
for	O
a	O
specialized	O
three-valued	B-Language
logic	I-Language
(	O
3VL	B-Language
)	O
.	O
</s>
<s>
The	O
rules	O
governing	O
SQL	B-Language
three-valued	B-Language
logic	I-Language
are	O
shown	O
in	O
the	O
tables	O
below	O
(	O
p	O
and	O
q	O
represent	O
logical	O
states	O
)	O
"	O
The	O
truth	O
tables	O
SQL	B-Language
uses	O
for	O
AND	O
,	O
OR	O
,	O
and	O
NOT	O
correspond	O
to	O
a	O
common	O
fragment	O
of	O
the	O
Kleene	O
and	O
Łukasiewicz	O
three-valued	B-Language
logic	I-Language
(	O
which	O
differ	O
in	O
their	O
definition	O
of	O
implication	O
,	O
however	O
SQL	B-Language
defines	O
no	O
such	O
operation	O
)	O
.	O
</s>
<s>
SQL	B-Language
three-valued	B-Language
logic	I-Language
is	O
encountered	O
in	O
Data	B-Language
Manipulation	I-Language
Language	I-Language
(	O
DML	O
)	O
in	O
comparison	O
predicates	O
of	O
DML	O
statements	O
and	O
queries	B-Language
.	O
</s>
<s>
The	O
WHERE	B-Language
clause	O
causes	O
the	O
DML	O
statement	O
to	O
act	O
on	O
only	O
those	O
rows	O
for	O
which	O
the	O
predicate	O
evaluates	O
to	O
True	O
.	O
</s>
<s>
Rows	O
for	O
which	O
the	O
predicate	O
evaluates	O
to	O
either	O
False	O
or	O
Unknown	O
are	O
not	O
acted	O
on	O
by	O
INSERT	B-Language
,	O
UPDATE	B-Language
,	O
or	O
DELETE	B-Language
DML	O
statements	O
,	O
and	O
are	O
discarded	O
by	O
SELECT	B-Language
queries	B-Language
.	O
</s>
<s>
The	O
example	O
query	B-Language
above	O
logically	O
always	O
returns	O
zero	O
rows	O
because	O
the	O
comparison	O
of	O
the	O
i	O
column	B-Application
with	O
Null	O
always	O
returns	O
Unknown	O
,	O
even	O
for	O
those	O
rows	O
where	B-Language
i	O
is	O
Null	O
.	O
</s>
<s>
The	O
Unknown	O
result	O
causes	O
the	O
SELECT	B-Language
statement	O
to	O
summarily	O
discard	O
each	O
and	O
every	O
row	O
.	O
</s>
<s>
(	O
However	O
,	O
in	O
practice	O
,	O
some	O
SQL	B-Language
tools	O
will	O
retrieve	O
rows	O
using	O
a	O
comparison	O
with	O
Null	O
.	O
)	O
</s>
<s>
Basic	O
SQL	B-Language
comparison	O
operators	O
always	O
return	O
Unknown	O
when	O
comparing	O
anything	O
with	O
Null	O
,	O
so	O
the	O
SQL	B-Language
standard	O
provides	O
for	O
two	O
special	O
Null-specific	O
comparison	O
predicates	O
.	O
</s>
<s>
The	O
SQL	B-Language
standard	O
contains	O
the	O
optional	O
feature	O
F571	O
"	O
Truth	O
value	O
tests	O
"	O
that	O
introduces	O
three	O
additional	O
logical	O
unary	O
operators	O
(	O
six	O
in	O
fact	O
,	O
if	B-Language
we	O
count	O
their	O
negation	O
,	O
which	O
is	O
part	O
of	O
their	O
syntax	O
)	O
,	O
also	O
using	O
postfix	O
notation	O
.	O
</s>
<s>
The	O
F571	O
feature	O
is	O
orthogonal	O
to	O
the	O
presence	O
of	O
the	O
boolean	O
datatype	O
in	O
SQL	B-Language
(	O
discussed	O
later	O
in	O
this	O
article	O
)	O
and	O
,	O
despite	O
syntactic	O
similarities	O
,	O
F571	O
does	O
not	O
introduce	O
boolean	O
or	O
three-valued	O
literals	O
in	O
the	O
language	O
.	O
</s>
<s>
The	O
F571	O
feature	O
was	O
actually	O
present	O
in	O
SQL92	B-Language
,	O
well	O
before	O
the	O
boolean	O
datatype	O
was	O
introduced	O
to	O
the	O
standard	O
in	O
1999	O
.	O
</s>
<s>
The	O
F571	O
feature	O
is	O
implemented	O
by	O
few	O
systems	O
however	O
;	O
PostgreSQL	B-Application
is	O
one	O
of	O
those	O
implementing	O
it	O
.	O
</s>
<s>
The	O
addition	O
of	O
IS	O
UNKNOWN	O
to	O
the	O
other	O
operators	O
of	O
SQL	B-Language
's	O
three-valued	B-Language
logic	I-Language
makes	O
the	O
SQL	B-Language
three-valued	B-Language
logic	I-Language
functionally	O
complete	O
,	O
meaning	O
its	O
logical	O
operators	O
can	O
express	O
(	O
in	O
combination	O
)	O
any	O
conceivable	O
three-valued	O
logical	O
function	O
.	O
</s>
<s>
In	O
SQL	B-Language
's	O
three-valued	B-Language
logic	I-Language
the	O
law	O
of	O
the	O
excluded	O
middle	O
,	O
p	O
OR	O
NOT	O
p	O
,	O
no	O
longer	O
evaluates	O
to	O
true	O
for	O
all	O
p	O
.	O
More	O
precisely	O
,	O
in	O
SQL	B-Language
's	O
three-valued	B-Language
logic	I-Language
p	O
OR	O
NOT	O
p	O
is	O
unknown	O
precisely	O
when	O
p	O
is	O
unknown	O
and	O
true	O
otherwise	O
.	O
</s>
<s>
if	B-Language
the	O
column	B-Application
x	O
contains	O
any	O
Nulls	O
;	O
in	O
that	O
case	O
the	O
second	O
query	B-Language
would	O
return	O
some	O
rows	O
the	O
first	O
one	O
does	O
not	O
return	O
,	O
namely	O
all	O
those	O
in	O
which	O
x	O
is	O
Null	O
.	O
</s>
<s>
In	O
classical	O
two-valued	O
logic	O
,	O
the	O
law	O
of	O
the	O
excluded	O
middle	O
would	O
allow	O
the	O
simplification	O
of	O
the	O
WHERE	B-Language
clause	O
predicate	O
,	O
in	O
fact	O
its	O
elimination	O
.	O
</s>
<s>
Attempting	O
to	O
apply	O
the	O
law	O
of	O
the	O
excluded	O
middle	O
to	O
SQL	B-Language
's	O
3VL	B-Language
is	O
effectively	O
a	O
false	O
dichotomy	O
.	O
</s>
<s>
The	O
second	O
query	B-Language
is	O
actually	O
equivalent	O
with	O
:	O
</s>
<s>
Thus	O
,	O
to	O
correctly	O
simplify	O
the	O
first	O
statement	O
in	O
SQL	B-Language
requires	O
that	O
we	O
return	O
all	O
rows	O
in	O
which	O
x	O
is	O
not	O
null	O
.	O
</s>
<s>
In	O
view	O
of	O
the	O
above	O
,	O
observe	O
that	O
for	O
SQL	B-Language
's	O
WHERE	B-Language
clause	O
a	O
tautology	O
similar	O
to	O
the	O
law	O
of	O
excluded	O
middle	O
can	O
be	O
written	O
.	O
</s>
<s>
There	O
are	O
some	O
SQL	B-Language
expressions	O
in	O
which	O
it	O
is	O
less	O
obvious	O
where	B-Language
the	O
false	O
dilemma	O
occurs	O
,	O
for	O
example	O
:	O
</s>
<s>
(	O
The	O
CAST	O
in	O
this	O
example	O
is	O
needed	O
only	O
in	O
some	O
SQL	B-Language
implementations	O
like	O
PostgreSQL	B-Application
,	O
which	O
would	O
reject	O
it	O
with	O
a	O
type	O
checking	O
error	O
otherwise	O
.	O
</s>
<s>
In	O
many	O
systems	O
plain	O
SELECT	B-Language
NULL	O
works	O
in	O
the	O
subquery	O
.	O
)	O
</s>
<s>
Joins	O
evaluate	O
using	O
the	O
same	O
comparison	O
rules	O
as	O
for	O
WHERE	B-Language
clauses	O
.	O
</s>
<s>
Therefore	O
,	O
care	O
must	O
be	O
taken	O
when	O
using	O
nullable	O
columns	O
in	O
SQL	B-Language
join	I-Language
criteria	O
.	O
</s>
<s>
In	O
particular	O
a	O
table	O
containing	O
any	O
nulls	O
is	O
not	O
equal	O
with	O
a	O
natural	O
self-join	O
of	O
itself	O
,	O
meaning	O
that	O
whereas	O
is	O
true	O
for	O
any	O
relation	O
R	O
in	O
relational	B-Algorithm
algebra	I-Algorithm
,	O
a	O
SQL	B-Language
self-join	O
will	O
exclude	O
all	O
rows	O
having	O
a	O
Null	O
anywhere	O
.	O
</s>
<s>
The	O
SQL	B-Language
COALESCE	O
function	O
or	O
CASE	O
expressions	O
can	O
be	O
used	O
to	O
"	O
simulate	O
"	O
Null	O
equality	O
in	O
join	O
criteria	O
,	O
and	O
the	O
IS	O
NULL	O
and	O
IS	O
NOT	O
NULL	O
predicates	O
can	O
be	O
used	O
in	O
the	O
join	O
criteria	O
as	O
well	O
.	O
</s>
<s>
SQL	B-Language
provides	O
two	O
flavours	O
of	O
conditional	B-Language
expressions	O
.	O
</s>
<s>
The	O
other	O
is	O
called	O
a	O
"	O
searched	O
CASE	O
"	O
in	O
the	O
standard	O
,	O
and	O
operates	O
like	O
an	O
if	B-Language
...	O
elseif	B-Language
.	O
</s>
<s>
The	O
simple	O
CASE	O
expressions	O
use	O
implicit	O
equality	O
comparisons	O
which	O
operate	O
under	O
the	O
same	O
rules	O
as	O
the	O
DML	O
WHERE	B-Language
clause	O
rules	O
for	O
Null	O
.	O
</s>
<s>
Because	O
the	O
expression	O
i	O
=	O
NULL	O
evaluates	O
to	O
Unknown	O
no	O
matter	O
what	O
value	O
column	B-Application
i	O
contains	O
(	O
even	O
if	B-Language
it	O
contains	O
Null	O
)	O
,	O
the	O
string	O
'	O
Is	O
Null	O
 '	O
will	O
never	O
be	O
returned	O
.	O
</s>
<s>
Oracle	O
's	O
dialect	O
of	O
SQL	B-Language
provides	O
a	O
built-in	O
function	O
DECODE	O
which	O
can	O
be	O
used	O
instead	O
of	O
the	O
simple	O
CASE	O
expressions	O
and	O
considers	O
two	O
nulls	O
equal	O
.	O
</s>
<s>
Finally	O
,	O
all	O
these	O
constructs	O
return	O
a	O
NULL	O
if	B-Language
no	O
match	O
is	O
found	O
;	O
they	O
have	O
a	O
default	O
ELSE	B-Language
NULL	O
clause	O
.	O
</s>
<s>
SQL/PSM	B-Language
(	O
SQL	B-Language
Persistent	O
Stored	O
Modules	O
)	O
defines	O
procedural	B-Application
extensions	O
for	O
SQL	B-Language
,	O
such	O
as	O
the	O
IF	B-Language
statement	O
.	O
</s>
<s>
However	O
,	O
the	O
major	O
SQL	B-Language
vendors	O
have	O
historically	O
included	O
their	O
own	O
proprietary	O
procedural	B-Application
extensions	O
.	O
</s>
<s>
Procedural	B-Application
extensions	O
for	O
looping	O
and	O
comparisons	O
operate	O
under	O
Null	O
comparison	O
rules	O
similar	O
to	O
those	O
for	O
DML	O
statements	O
and	O
queries	B-Language
.	O
</s>
<s>
The	O
following	O
code	O
fragment	O
,	O
in	O
ISO	O
SQL	B-Language
standard	O
format	O
,	O
demonstrates	O
the	O
use	O
of	O
Null	O
3VL	B-Language
in	O
an	O
IF	B-Language
statement	O
.	O
</s>
<s>
The	O
IF	B-Language
statement	O
performs	O
actions	O
only	O
for	O
those	O
comparisons	O
that	O
evaluate	O
to	O
True	O
.	O
</s>
<s>
For	O
statements	O
that	O
evaluate	O
to	O
False	O
or	O
Unknown	O
,	O
the	O
IF	B-Language
statement	O
passes	O
control	O
to	O
the	O
ELSEIF	B-Language
clause	O
,	O
and	O
finally	O
to	O
the	O
ELSE	B-Language
clause	O
.	O
</s>
<s>
The	O
groundbreaking	O
work	O
of	O
T	O
.	O
Imieliński	O
and	O
W	O
.	O
Lipski	O
Jr.	O
(	O
1984	O
)	O
provided	O
a	O
framework	O
in	O
which	O
to	O
evaluate	O
the	O
intended	O
semantics	O
of	O
various	O
proposals	O
to	O
implement	O
missing-value	O
semantics	O
,	O
that	O
is	O
referred	O
to	O
as	O
Imieliński-Lipski	B-Application
Algebras	I-Application
.	O
</s>
<s>
A	O
construct	O
(	O
such	O
as	O
a	O
Codd	O
table	O
)	O
is	O
said	O
to	O
be	O
a	O
strong	O
representation	O
system	O
(	O
of	O
missing	O
information	O
)	O
if	B-Language
any	O
answer	O
to	O
a	O
query	B-Language
made	O
on	O
the	O
construct	O
can	O
be	O
particularized	O
to	O
obtain	O
an	O
answer	O
for	O
any	O
corresponding	O
query	B-Language
on	O
the	O
relations	O
it	O
represents	O
,	O
which	O
are	O
seen	O
as	O
models	O
of	O
the	O
construct	O
.	O
</s>
<s>
More	O
precisely	O
,	O
if	B-Language
is	O
a	O
query	B-Language
formula	O
in	O
the	O
relational	B-Algorithm
algebra	I-Algorithm
(	O
of	O
"	O
pure	O
"	O
relations	O
)	O
and	O
if	B-Language
is	O
its	O
lifting	O
to	O
a	O
construct	O
intended	O
to	O
represent	O
missing	O
information	O
,	O
a	O
strong	O
representation	O
has	O
the	O
property	O
that	O
for	O
any	O
query	B-Language
q	O
and	O
(	O
table	O
)	O
construct	O
T	O
,	O
lifts	O
all	O
the	O
answers	O
to	O
the	O
construct	O
,	O
i.e.	O
</s>
<s>
(	O
The	O
above	O
has	O
to	O
hold	O
for	O
queries	B-Language
taking	O
any	O
number	O
of	O
tables	O
as	O
arguments	O
,	O
but	O
the	O
restriction	O
to	O
one	O
table	O
suffices	O
for	O
this	O
discussion	O
.	O
)	O
</s>
<s>
Clearly	O
Codd	O
tables	O
do	O
not	O
have	O
this	O
strong	O
property	O
if	B-Language
selections	O
and	O
projections	O
are	O
considered	O
as	O
part	O
of	O
the	O
query	B-Language
language	O
.	O
</s>
<s>
A	O
device	O
,	O
mostly	O
of	O
theoretical	O
interest	O
,	O
called	O
conditional	B-Language
table	O
(	O
or	O
c-table	O
)	O
can	O
however	O
represent	O
such	O
an	O
answer	O
:	O
</s>
<s>
where	B-Language
the	O
condition	O
column	B-Application
is	O
interpreted	O
as	O
the	O
row	O
does	O
n't	O
exist	O
if	B-Language
the	O
condition	O
is	O
false	O
.	O
</s>
<s>
It	O
turns	O
out	O
that	O
because	O
the	O
formulas	O
in	O
the	O
condition	O
column	B-Application
of	O
a	O
c-table	O
can	O
be	O
arbitrary	O
propositional	O
logic	O
formulas	O
,	O
an	O
algorithm	O
for	O
the	O
problem	O
whether	O
a	O
c-table	O
represents	O
some	O
concrete	O
relation	O
has	O
a	O
co-NP-complete	O
complexity	O
,	O
thus	O
is	O
of	O
little	O
practical	O
worth	O
.	O
</s>
<s>
Imielinski	O
and	O
Lipski	O
introduced	O
the	O
notion	O
of	O
weak	O
representation	O
,	O
which	O
essentially	O
allows	O
(	O
lifted	O
)	O
queries	B-Language
over	O
a	O
construct	O
to	O
return	O
a	O
representation	O
only	O
for	O
sure	O
information	O
,	O
i.e.	O
</s>
<s>
if	B-Language
it	O
's	O
valid	O
for	O
all	O
"	O
possible	O
world	O
"	O
instantiations	O
(	O
models	O
)	O
of	O
the	O
construct	O
.	O
</s>
<s>
the	O
sure	O
information	O
)	O
of	O
the	O
query	B-Language
selecting	O
is	O
actually	O
empty	O
because	O
,	O
for	O
instance	O
,	O
the	O
(	O
unlifted	O
)	O
query	B-Language
returns	O
no	O
rows	O
for	O
the	O
relation	O
EmpH37	O
.	O
</s>
<s>
More	O
generally	O
,	O
it	O
was	O
shown	O
by	O
Imielinski	O
and	O
Lipski	O
that	O
Codd	O
tables	O
are	O
a	O
weak	O
representation	O
system	O
if	B-Language
the	O
query	B-Language
language	O
is	O
restricted	O
to	O
projections	O
,	O
selections	O
(	O
and	O
renaming	O
of	O
columns	O
)	O
.	O
</s>
<s>
However	O
,	O
as	O
soon	O
as	O
we	O
add	O
either	O
joins	O
or	O
unions	O
to	O
the	O
query	B-Language
language	O
,	O
even	O
this	O
weak	O
property	O
is	O
lost	O
,	O
as	O
evidenced	O
in	O
the	O
next	O
section	O
.	O
</s>
<s>
Consider	O
the	O
following	O
query	B-Language
over	O
the	O
same	O
Codd	O
table	O
from	O
the	O
previous	O
section	O
:	O
</s>
<s>
Whatever	O
concrete	O
value	O
one	O
would	O
choose	O
for	O
the	O
age	O
of	O
Harriet	O
,	O
the	O
above	O
query	B-Language
will	O
return	O
the	O
full	O
column	B-Application
of	O
names	O
of	O
any	O
model	O
of	O
,	O
but	O
when	O
the	O
(	O
lifted	O
)	O
query	B-Language
is	O
run	O
on	O
itself	O
,	O
Harriet	O
will	O
always	O
be	O
missing	O
,	O
i.e.	O
</s>
<s>
Thus	O
when	O
unions	O
are	O
added	O
to	O
the	O
query	B-Language
language	O
,	O
Codd	O
tables	O
are	O
not	O
even	O
a	O
weak	O
representation	O
system	O
of	O
missing	O
information	O
,	O
meaning	O
that	O
queries	B-Language
over	O
them	O
do	O
n't	O
even	O
report	O
all	O
sure	O
information	O
.	O
</s>
<s>
It	O
's	O
important	O
to	O
note	O
here	O
that	O
semantics	O
of	O
UNION	O
on	O
Nulls	O
,	O
which	O
are	O
discussed	O
in	O
a	O
later	O
section	O
,	O
did	O
not	O
even	O
come	O
into	O
play	O
in	O
this	O
query	B-Language
.	O
</s>
<s>
The	O
"	O
forgetful	O
"	O
nature	O
of	O
the	O
two	O
sub-queries	O
was	O
all	O
that	O
it	O
took	O
to	O
guarantee	O
that	O
some	O
sure	O
information	O
went	O
unreported	O
when	O
the	O
above	O
query	B-Language
was	O
run	O
on	O
the	O
Codd	O
table	O
Emp	O
.	O
</s>
<s>
For	O
natural	O
joins	O
,	O
the	O
example	O
needed	O
to	O
show	O
that	O
sure	O
information	O
may	O
be	O
unreported	O
by	O
some	O
query	B-Language
is	O
slightly	O
more	O
complicated	O
.	O
</s>
<s>
This	O
observation	O
suggests	O
that	O
a	O
relatively	O
simple	O
improvement	O
of	O
Codd	O
tables	O
(	O
which	O
works	O
correctly	O
for	O
this	O
example	O
)	O
would	O
be	O
to	O
use	O
Skolem	B-Application
constants	I-Application
(	O
meaning	O
Skolem	B-Application
functions	I-Application
which	O
are	O
also	O
constant	O
functions	O
)	O
,	O
say	O
ω12	O
and	O
ω22	O
instead	O
of	O
a	O
single	O
NULL	O
symbol	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
still	O
not	O
a	O
complete	O
solution	O
for	O
incomplete	O
information	O
in	O
the	O
sense	O
that	O
v-tables	O
are	O
only	O
a	O
weak	O
representation	O
for	O
queries	B-Language
not	O
using	O
any	O
negations	O
in	O
selection	O
(	O
and	O
not	O
using	O
any	O
set	O
difference	O
either	O
)	O
.	O
</s>
<s>
The	O
first	O
example	O
considered	O
in	O
this	O
section	O
is	O
using	O
a	O
negative	O
selection	O
clause	O
,	O
,	O
so	O
it	O
is	O
also	O
an	O
example	O
where	B-Language
v-tables	O
queries	B-Language
would	O
not	O
report	O
sure	O
information	O
.	O
</s>
<s>
The	O
primary	O
place	O
in	O
which	O
SQL	B-Language
three-valued	B-Language
logic	I-Language
intersects	O
with	O
SQL	B-Language
Data	B-Language
Definition	I-Language
Language	I-Language
(	O
DDL	O
)	O
is	O
in	O
the	O
form	O
of	O
check	B-Language
constraints	I-Language
.	O
</s>
<s>
A	O
check	B-Language
constraint	I-Language
placed	O
on	O
a	O
column	B-Application
operates	O
under	O
a	O
slightly	O
different	O
set	O
of	O
rules	O
than	O
those	O
for	O
the	O
DML	O
WHERE	B-Language
clause	O
.	O
</s>
<s>
While	O
a	O
DML	O
WHERE	B-Language
clause	O
must	O
evaluate	O
to	O
True	O
for	O
a	O
row	O
,	O
a	O
check	B-Language
constraint	I-Language
must	O
not	O
evaluate	O
to	O
False	O
.	O
</s>
<s>
This	O
means	O
that	O
a	O
check	B-Language
constraint	I-Language
will	O
succeed	O
if	B-Language
the	O
result	O
of	O
the	O
check	O
is	O
either	O
True	O
or	O
Unknown	O
.	O
</s>
<s>
The	O
following	O
example	O
table	O
with	O
a	O
check	B-Language
constraint	I-Language
will	O
prohibit	O
any	O
integer	O
values	O
from	O
being	O
inserted	O
into	O
column	B-Application
i	O
,	O
but	O
will	O
allow	O
Null	O
to	O
be	O
inserted	O
since	O
the	O
result	O
of	O
the	O
check	O
will	O
always	O
evaluate	O
to	O
Unknown	O
for	O
Nulls	O
.	O
</s>
<s>
In	O
order	O
to	O
constrain	O
a	O
column	B-Application
to	O
reject	O
Nulls	O
,	O
the	O
NOT	O
NULL	O
constraint	O
can	O
be	O
applied	O
,	O
as	O
shown	O
in	O
the	O
example	O
below	O
.	O
</s>
<s>
The	O
NOT	O
NULL	O
constraint	O
is	O
semantically	O
equivalent	O
to	O
a	O
check	B-Language
constraint	I-Language
with	O
an	O
IS	O
NOT	O
NULL	O
predicate	O
.	O
</s>
<s>
By	O
default	O
check	B-Language
constraints	I-Language
against	O
foreign	B-Application
keys	I-Application
succeed	O
if	B-Language
any	O
of	O
the	O
fields	O
in	O
such	O
keys	O
are	O
Null	O
.	O
</s>
<s>
would	O
allow	O
insertion	O
of	O
rows	O
where	B-Language
author_last	O
or	O
author_first	O
are	O
irrespective	O
of	O
how	O
the	O
table	O
Authors	O
is	O
defined	O
or	O
what	O
it	O
contains	O
.	O
</s>
<s>
For	O
example	O
,	O
if	B-Language
Authors	O
contained	O
only	O
,	O
then	O
would	O
satisfy	O
the	O
foreign	B-Application
key	I-Application
constraint	I-Application
.	O
</s>
<s>
SQL-92	B-Language
added	O
two	O
extra	O
options	O
for	O
narrowing	O
down	O
the	O
matches	O
in	O
such	O
cases	O
.	O
</s>
<s>
If	B-Language
MATCH	O
PARTIAL	O
is	O
added	O
after	O
the	O
REFERENCES	O
declaration	O
then	O
any	O
non-null	O
must	O
match	O
the	O
foreign	B-Application
key	I-Application
,	O
e.g.	O
</s>
<s>
Finally	O
,	O
if	B-Language
MATCH	O
FULL	O
is	O
added	O
then	O
would	O
not	O
match	O
the	O
constraint	O
either	O
,	O
but	O
would	O
still	O
match	O
it	O
.	O
</s>
<s>
SQL	B-Language
outer	B-Language
joins	I-Language
,	O
including	O
left	O
outer	B-Language
joins	I-Language
,	O
right	O
outer	B-Language
joins	I-Language
,	O
and	O
full	O
outer	B-Language
joins	I-Language
,	O
automatically	O
produce	O
Nulls	O
as	O
placeholders	O
for	O
missing	O
values	O
in	O
related	O
tables	O
.	O
</s>
<s>
For	O
left	O
outer	B-Language
joins	I-Language
,	O
for	O
instance	O
,	O
Nulls	O
are	O
produced	O
in	O
place	O
of	O
rows	O
missing	O
from	O
the	O
table	O
appearing	O
on	O
the	O
right-hand	O
side	O
of	O
the	O
LEFT	O
OUTER	B-Language
JOIN	I-Language
operator	O
.	O
</s>
<s>
The	O
following	O
simple	O
example	O
uses	O
two	O
tables	O
to	O
demonstrate	O
Null	O
placeholder	O
production	O
in	O
a	O
left	O
outer	B-Language
join	I-Language
.	O
</s>
<s>
The	O
following	O
sample	O
SQL	B-Language
query	I-Language
performs	O
a	O
left	O
outer	B-Language
join	I-Language
on	O
these	O
two	O
tables	O
.	O
</s>
<s>
The	O
result	B-Application
set	I-Application
generated	O
by	O
this	O
query	B-Language
demonstrates	O
how	O
SQL	B-Language
uses	O
Null	O
as	O
a	O
placeholder	O
for	O
values	O
missing	O
from	O
the	O
right-hand	O
(	O
PhoneNumber	O
)	O
table	O
,	O
as	O
shown	O
below	O
.	O
</s>
<s>
SQL	B-Language
defines	O
aggregate	O
functions	O
to	O
simplify	O
server-side	O
aggregate	O
calculations	O
on	O
data	O
.	O
</s>
<s>
A	O
well-known	O
side	O
effect	O
of	O
this	O
is	O
that	O
in	O
SQL	B-Language
AVG(z )	O
is	O
equivalent	O
with	O
not	O
SUM(z )	O
/COUNT	O
( *	O
)	O
but	O
SUM(z )	O
/COUNT	O
( z	O
)	O
.	O
</s>
<s>
This	O
query	B-Language
will	O
always	O
output	O
exactly	O
one	O
row	O
,	O
counting	O
of	O
the	O
number	O
of	O
employees	O
whose	O
last	O
name	O
contains	O
"	O
Jones	O
"	O
,	O
and	O
giving	O
the	O
minimum	O
and	O
maximum	O
wage	O
found	O
for	O
those	O
employees	O
.	O
</s>
<s>
However	O
,	O
what	O
happens	O
if	B-Language
none	O
of	O
the	O
employees	O
fit	O
the	O
given	O
criteria	O
?	O
</s>
<s>
Because	O
SQL:2003	B-Language
defines	O
all	O
Null	O
markers	O
as	O
being	O
unequal	O
to	O
one	O
another	O
,	O
a	O
special	O
definition	O
was	O
required	O
in	O
order	O
to	O
group	O
Nulls	O
together	O
when	O
performing	O
certain	O
operations	O
.	O
</s>
<s>
SQL	B-Language
defines	O
"	O
any	O
two	O
values	O
that	O
are	O
equal	O
to	O
one	O
another	O
,	O
or	O
any	O
two	O
Nulls	O
"	O
,	O
as	O
"	O
not	O
distinct	O
"	O
.	O
</s>
<s>
This	O
definition	O
of	O
not	O
distinct	O
allows	O
SQL	B-Language
to	O
group	O
and	O
sort	O
Nulls	O
when	O
the	O
GROUP	O
BY	O
clause	O
(	O
and	O
other	O
keywords	O
that	O
perform	O
grouping	O
)	O
are	O
used	O
.	O
</s>
<s>
Other	O
SQL	B-Language
operations	O
,	O
clauses	O
,	O
and	O
keywords	O
use	O
"	O
not	O
distinct	O
"	O
in	O
their	O
treatment	O
of	O
Nulls	O
.	O
</s>
<s>
The	O
principle	O
that	O
Nulls	O
are	O
n't	O
equal	O
to	O
each	O
other	O
(	O
but	O
rather	O
that	O
the	O
result	O
is	O
Unknown	O
)	O
is	O
effectively	O
violated	O
in	O
the	O
SQL	B-Language
specification	O
for	O
the	O
UNION	O
operator	O
,	O
which	O
does	O
identify	O
nulls	O
with	O
each	O
other	O
.	O
</s>
<s>
Consequently	O
,	O
some	O
set	O
operations	O
in	O
SQL	B-Language
,	O
like	O
union	O
or	O
difference	O
,	O
may	O
produce	O
results	O
not	O
representing	O
sure	O
information	O
,	O
unlike	O
operations	O
involving	O
explicit	O
comparisons	O
with	O
NULL	O
(	O
e.g.	O
</s>
<s>
those	O
in	O
a	O
WHERE	B-Language
clause	O
discussed	O
above	O
)	O
.	O
</s>
<s>
In	O
Codd	O
's	O
1979	O
proposal	O
(	O
which	O
was	O
basically	O
adopted	O
by	O
SQL92	B-Language
)	O
this	O
semantic	O
inconsistency	O
is	O
rationalized	O
by	O
arguing	O
that	O
removal	O
of	O
duplicates	O
in	O
set	O
operations	O
happens	O
"	O
at	O
a	O
lower	O
level	O
of	O
detail	O
than	O
equality	O
testing	O
in	O
the	O
evaluation	O
of	O
retrieval	O
operations.	O
"	O
</s>
<s>
The	O
SQL	B-Language
standard	O
does	O
not	O
explicitly	O
define	O
a	O
default	O
sort	O
order	O
for	O
Nulls	O
.	O
</s>
<s>
Some	O
SQL	B-Language
products	O
do	O
not	O
index	O
keys	O
containing	O
NULLs	O
.	O
</s>
<s>
In	O
cases	O
where	B-Language
the	O
index	O
enforces	O
uniqueness	O
,	O
NULLs	O
are	O
excluded	O
from	O
the	O
index	O
and	O
uniqueness	O
is	O
not	O
enforced	O
between	O
NULLs	O
.	O
</s>
<s>
Again	O
,	O
quoting	O
from	O
the	O
PostgreSQL	B-Application
documentation	O
:	O
</s>
<s>
This	O
is	O
consistent	O
with	O
the	O
SQL:2003-defined	O
behavior	O
of	O
scalar	O
Null	O
comparisons	O
.	O
</s>
<s>
Another	O
method	O
of	O
indexing	O
Nulls	O
involves	O
handling	O
them	O
as	O
not	O
distinct	O
in	O
accordance	O
with	O
the	O
SQL:2003-defined	O
behavior	O
.	O
</s>
<s>
For	O
example	O
,	O
Microsoft	B-Application
SQL	I-Application
Server	I-Application
documentation	O
states	O
the	O
following	O
:	O
</s>
<s>
Both	O
of	O
these	O
indexing	O
strategies	O
are	O
consistent	O
with	O
the	O
SQL:2003-defined	O
behavior	O
of	O
Nulls	O
.	O
</s>
<s>
Because	O
indexing	O
methodologies	O
are	O
not	O
explicitly	O
defined	O
by	O
the	O
SQL:2003	B-Language
standard	O
,	O
indexing	O
strategies	O
for	O
Nulls	O
are	O
left	O
entirely	O
to	O
the	O
vendors	O
to	O
design	O
and	O
implement	O
.	O
</s>
<s>
SQL	B-Language
defines	O
two	O
functions	O
to	O
explicitly	O
handle	O
Nulls	O
:	O
NULLIF	B-Language
and	O
COALESCE	O
.	O
</s>
<s>
The	O
NULLIF	B-Language
function	O
accepts	O
two	O
parameters	O
.	O
</s>
<s>
If	B-Language
the	O
first	O
parameter	O
is	O
equal	O
to	O
the	O
second	O
parameter	O
,	O
NULLIF	B-Language
returns	O
Null	O
.	O
</s>
<s>
Thus	O
,	O
NULLIF	B-Language
is	O
an	O
abbreviation	O
for	O
the	O
following	O
CASE	O
expression	O
:	O
</s>
<s>
COALESCE	O
is	O
defined	O
as	O
shorthand	O
for	O
the	O
following	O
SQL	B-Language
CASE	O
expression	O
:	O
</s>
<s>
Some	O
SQL	B-Language
DBMSs	O
implement	O
vendor-specific	O
functions	O
similar	O
to	O
COALESCE	O
.	O
</s>
<s>
Transact-SQL	B-Language
)	O
implement	O
an	O
ISNULL	B-Language
function	O
,	O
or	O
other	O
similar	O
functions	O
that	O
are	O
functionally	O
similar	O
to	O
COALESCE	O
.	O
</s>
<s>
(	O
See	O
Is	B-Language
functions	I-Language
for	O
more	O
on	O
the	O
IS	B-Language
functions	I-Language
in	O
Transact-SQL	B-Language
.	O
)	O
</s>
<s>
It	O
returns	O
the	O
first	O
non-NULL	O
parameter	O
or	O
NULL	O
if	B-Language
all	O
parameters	O
are	O
NULL	O
.	O
</s>
<s>
A	O
use	O
case	O
of	O
this	O
function	O
is	O
to	O
replace	O
in	O
an	O
expression	O
a	O
NULL	O
by	O
a	O
value	O
like	O
in	O
NVL(SALARY, 0 )	O
which	O
says	O
,	O
'	O
if	B-Language
SALARY	O
is	O
NULL	O
,	O
replace	O
it	O
with	O
the	O
value	O
0	O
 '	O
.	O
</s>
<s>
The	O
NULL	O
literal	O
is	O
untyped	O
in	O
SQL	B-Language
,	O
meaning	O
that	O
it	O
is	O
not	O
designated	O
as	O
an	O
integer	O
,	O
character	O
,	O
or	O
any	O
other	O
specific	O
data	O
type	O
.	O
</s>
<s>
For	O
instance	O
,	O
if	B-Language
overloaded	B-Language
functions	I-Language
are	O
supported	O
by	O
the	O
RDBMS	O
,	O
SQL	B-Language
might	O
not	O
be	O
able	O
to	O
automatically	O
resolve	O
to	O
the	O
correct	O
function	O
without	O
knowing	O
the	O
data	O
types	O
of	O
all	O
parameters	O
,	O
including	O
those	O
for	O
which	O
Null	O
is	O
passed	O
.	O
</s>
<s>
Conversion	O
from	O
the	O
NULL	O
literal	O
to	O
a	O
Null	O
of	O
a	O
specific	O
type	O
is	O
possible	O
using	O
the	O
CAST	O
introduced	O
in	O
SQL-92	B-Language
.	O
</s>
<s>
The	O
actual	O
typing	O
of	O
Unknown	O
(	O
distinct	O
or	O
not	O
from	O
NULL	O
itself	O
)	O
varies	O
between	O
SQL	B-Language
implementations	O
.	O
</s>
<s>
SQLite	B-Language
or	O
PostgreSQL	B-Application
)	O
which	O
unify	O
a	O
NULL	O
boolean	O
with	O
Unknown	O
but	O
fails	O
to	O
parse	O
in	O
others	O
(	O
e.g.	O
</s>
<s>
in	O
SQL	B-Operating_System
Server	I-Operating_System
Compact	I-Operating_System
)	O
.	O
</s>
<s>
MySQL	B-Application
behaves	O
similarly	O
to	O
PostgreSQL	B-Application
in	O
this	O
regard	O
(	O
with	O
the	O
minor	O
exception	O
that	O
MySQL	B-Application
regards	O
TRUE	O
and	O
FALSE	O
as	O
no	O
different	O
from	O
the	O
ordinary	O
integers	O
1	O
and	O
0	O
)	O
.	O
</s>
<s>
PostgreSQL	B-Application
additionally	O
implements	O
a	O
IS	O
UNKNOWN	O
predicate	O
,	O
which	O
can	O
be	O
used	O
to	O
test	O
whether	O
a	O
three-value	O
logical	O
outcome	O
is	O
Unknown	O
,	O
although	O
this	O
is	O
merely	O
syntactic	O
sugar	O
.	O
</s>
<s>
The	O
ISO	O
SQL:1999	B-Language
standard	O
introduced	O
the	O
BOOLEAN	O
data	O
type	O
to	O
SQL	B-Language
,	O
however	O
it	O
's	O
still	O
just	O
an	O
optional	O
,	O
non-core	O
feature	O
,	O
coded	O
T031	O
.	O
</s>
<s>
When	O
restricted	O
by	O
a	O
NOT	O
NULL	O
constraint	O
,	O
the	O
SQL	B-Language
BOOLEAN	O
works	O
like	O
the	O
Boolean	O
type	O
from	O
other	O
languages	O
.	O
</s>
<s>
As	O
discussed	O
above	O
,	O
in	O
the	O
PostgreSQL	B-Application
implementation	O
of	O
SQL	B-Language
,	O
Null	O
is	O
used	O
to	O
represent	O
all	O
UNKNOWN	O
results	O
,	O
including	O
the	O
UNKNOWN	O
BOOLEAN	O
.	O
</s>
<s>
PostgreSQL	B-Application
does	O
not	O
implement	O
the	O
UNKNOWN	O
literal	O
(	O
although	O
it	O
does	O
implement	O
the	O
IS	O
UNKNOWN	O
operator	O
,	O
which	O
is	O
an	O
orthogonal	O
feature	O
.	O
)	O
</s>
<s>
The	O
procedural	B-Application
part	O
of	O
Oracle	O
's	O
PL/SQL	B-Language
supports	O
BOOLEAN	O
however	O
variables	O
;	O
these	O
can	O
also	O
be	O
assigned	O
NULL	O
and	O
the	O
value	O
is	O
considered	O
the	O
same	O
as	O
UNKNOWN	O
.	O
</s>
<s>
Misunderstanding	O
of	O
how	O
Null	O
works	O
is	O
the	O
cause	O
of	O
a	O
great	O
number	O
of	O
errors	O
in	O
SQL	B-Language
code	O
,	O
both	O
in	O
ISO	O
standard	O
SQL	B-Language
statements	O
and	O
in	O
the	O
specific	O
SQL	B-Language
dialects	O
supported	O
by	O
real-world	O
database	O
management	O
systems	O
.	O
</s>
<s>
These	O
mistakes	O
are	O
usually	O
the	O
result	O
of	O
confusion	O
between	O
Null	O
and	O
either	O
0	O
(	O
zero	O
)	O
or	O
an	O
empty	O
string	O
(	O
a	O
string	O
value	O
with	O
a	O
length	O
of	O
zero	O
,	O
represented	O
in	O
SQL	B-Language
as	O
''	O
)	O
.	O
</s>
<s>
Null	O
is	O
defined	O
by	O
the	O
SQL	B-Language
standard	O
as	O
different	O
from	O
both	O
an	O
empty	O
string	O
and	O
the	O
numerical	O
value	O
0	O
,	O
however	O
.	O
</s>
<s>
According	O
to	O
the	O
SQL	B-Language
standard	O
this	O
is	O
an	O
invalid	O
syntax	O
and	O
shall	O
lead	O
to	O
an	O
error	O
message	O
or	O
an	O
exception	O
.	O
</s>
<s>
In	O
a	O
related	O
,	O
but	O
more	O
subtle	O
example	O
,	O
a	O
WHERE	B-Language
clause	O
or	O
conditional	B-Language
statement	O
might	O
compare	O
a	O
column	B-Application
's	O
value	O
with	O
a	O
constant	O
.	O
</s>
<s>
It	O
is	O
often	O
incorrectly	O
assumed	O
that	O
a	O
missing	O
value	O
would	O
be	O
"	O
less	O
than	O
"	O
or	O
"	O
not	O
equal	O
to	O
"	O
a	O
constant	O
if	B-Language
that	O
field	O
contains	O
Null	O
,	O
but	O
,	O
in	O
fact	O
,	O
such	O
expressions	O
return	O
Unknown	O
.	O
</s>
<s>
These	O
confusions	O
arise	O
because	O
the	O
Law	O
of	O
Identity	O
is	O
restricted	O
in	O
SQL	B-Language
's	O
logic	O
.	O
</s>
<s>
When	O
dealing	O
with	O
equality	O
comparisons	O
using	O
the	O
NULL	O
literal	O
or	O
the	O
UNKNOWN	O
truth-value	O
,	O
SQL	B-Language
will	O
always	O
return	O
UNKNOWN	O
as	O
the	O
result	O
of	O
the	O
expression	O
.	O
</s>
<s>
This	O
is	O
a	O
partial	O
equivalence	O
relation	O
and	O
makes	O
SQL	B-Language
an	O
example	O
of	O
a	O
Non-Reflexive	O
logic	O
.	O
</s>
<s>
This	O
can	O
lead	O
to	O
unexpected	O
results	O
,	O
if	B-Language
users	O
are	O
not	O
well	O
versed	O
in	O
3-value	O
logic	O
.	O
</s>
<s>
The	O
ISO	O
SQL	B-Language
implementation	O
of	O
Null	O
is	O
the	O
subject	O
of	O
criticism	O
,	O
debate	O
and	O
calls	O
for	O
change	O
.	O
</s>
<s>
In	O
The	O
Relational	B-Architecture
Model	I-Architecture
for	O
Database	O
Management	O
:	O
Version	O
2	O
,	O
Codd	O
suggested	O
that	O
the	O
SQL	B-Language
implementation	O
of	O
Null	O
was	O
flawed	O
and	O
should	O
be	O
replaced	O
by	O
two	O
distinct	O
Null-type	O
markers	O
.	O
</s>
<s>
Codd	O
's	O
recommendation	O
,	O
if	B-Language
accepted	O
,	O
would	O
have	O
required	O
the	O
implementation	O
of	O
a	O
four-valued	O
logic	O
in	O
SQL	B-Language
.	O
</s>
<s>
Others	O
have	O
suggested	O
adding	O
additional	O
Null-type	O
markers	O
to	O
Codd	O
's	O
recommendation	O
to	O
indicate	O
even	O
more	O
reasons	O
that	O
a	O
data	O
value	O
might	O
be	O
"	O
Missing	O
"	O
,	O
increasing	O
the	O
complexity	O
of	O
SQL	B-Language
's	O
logic	O
system	O
.	O
</s>
<s>
At	O
various	O
times	O
,	O
proposals	O
have	O
also	O
been	O
put	O
forth	O
to	O
implement	O
multiple	O
user-defined	O
Null	O
markers	O
in	O
SQL	B-Language
.	O
</s>
<s>
Chris	O
Date	O
and	O
Hugh	O
Darwen	O
,	O
authors	O
of	O
The	O
Third	O
Manifesto	O
,	O
have	O
suggested	O
that	O
the	O
SQL	B-Language
Null	O
implementation	O
is	O
inherently	O
flawed	O
and	O
should	O
be	O
eliminated	O
altogether	O
,	O
pointing	O
to	O
inconsistencies	O
and	O
flaws	O
in	O
the	O
implementation	O
of	O
SQL	B-Language
Null-handling	O
(	O
particularly	O
in	O
aggregate	O
functions	O
)	O
as	O
proof	O
that	O
the	O
entire	O
concept	O
of	O
Null	O
is	O
flawed	O
and	O
should	O
be	O
removed	O
from	O
the	O
relational	B-Architecture
model	I-Architecture
.	O
</s>
<s>
Another	O
point	O
of	O
conflict	O
concerning	O
Nulls	O
is	O
that	O
they	O
violate	O
the	O
closed-world	B-Application
assumption	I-Application
model	O
of	O
relational	B-Architecture
databases	O
by	O
introducing	O
an	O
open-world	B-Application
assumption	I-Application
into	O
it	O
.	O
</s>
<s>
The	O
closed	B-Application
world	I-Application
assumption	I-Application
,	O
as	O
it	O
pertains	O
to	O
databases	O
,	O
states	O
that	O
"	O
Everything	O
stated	O
by	O
the	O
database	O
,	O
either	O
explicitly	O
or	O
implicitly	O
,	O
is	O
true	O
;	O
everything	O
else	B-Language
is	O
false.	O
"	O
</s>
<s>
Nulls	O
,	O
however	O
,	O
operate	O
under	O
the	O
open	B-Application
world	I-Application
assumption	I-Application
,	O
in	O
which	O
some	O
items	O
stored	O
in	O
the	O
database	O
are	O
considered	O
unknown	O
,	O
making	O
the	O
database	O
's	O
stored	O
knowledge	O
of	O
the	O
world	O
incomplete	O
.	O
</s>
