<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: What is the deal with NULLs?</title>
	<atom:link href="http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/feed/" rel="self" type="application/rss+xml" />
	<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/</link>
	<description>Ideas on Databases, Logic, and Language by Jeff Davis</description>
	<lastBuildDate>Tue, 09 Mar 2010 07:41:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tim Bunce</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-163</link>
		<dc:creator>Tim Bunce</dc:creator>
		<pubDate>Mon, 07 Dec 2009 21:46:55 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-163</guid>
		<description>FYI Darren Duncan has been working on just such a project for several years.
http://pugs.postgresql.org/node/404
http://www.mail-archive.com/dbi-users@perl.org/msg31943.html</description>
		<content:encoded><![CDATA[<p>FYI Darren Duncan has been working on just such a project for several years.<br />
<a href="http://pugs.postgresql.org/node/404" rel="nofollow">http://pugs.postgresql.org/node/404</a><br />
<a href="http://www.mail-archive.com/dbi-users@perl.org/msg31943.html" rel="nofollow">http://www.mail-archive.com/dbi-users@perl.org/msg31943.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-96</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Sat, 15 Aug 2009 06:32:30 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-96</guid>
		<description>&gt; NULL is the empty set.
&gt;
&gt; Set operations can appear to be very similar to “normal” mathematical operations, but since they may be missing key properties of that operation (say closure), they act in what appears to be a non-intuitive fashion.

What set operations lack closure? As far as I know set operations are a well-defined mathematical system, and the empty set is just a value in that system. Sets are closed over the operations UNION, INTERSECT, DIFFERENCE, etc.

Set operations are nothing like NULL semantics, which involve 3VL and strange exceptions. You certainly can&#039;t explain all of my examples by just saying &quot;NULL is the empty set&quot;.

&gt; {NULL} != NULL (i.e. the set containing NULL != NULL alone)

If you do &quot;SELECT * FROM foo WHERE NULL = NULL&quot;, which NULL is &quot;{NULL}&quot; and which NULL is &quot;NULL&quot;? They look indistinguishable to me, but the predicate does not evaluate to TRUE.

&gt; Does that help anyone?

I think that this line of reasoning will lead to mistakes. For instance, how do you explain the fact that COUNT(*) doesn&#039;t ignore NULLs? Or that &quot;x IS NOT NULL&quot; is not the same as &quot;NOT x IS NULL&quot; for all x?</description>
		<content:encoded><![CDATA[<p>> NULL is the empty set.<br />
><br />
> Set operations can appear to be very similar to “normal” mathematical operations, but since they may be missing key properties of that operation (say closure), they act in what appears to be a non-intuitive fashion.</p>
<p>What set operations lack closure? As far as I know set operations are a well-defined mathematical system, and the empty set is just a value in that system. Sets are closed over the operations UNION, INTERSECT, DIFFERENCE, etc.</p>
<p>Set operations are nothing like NULL semantics, which involve 3VL and strange exceptions. You certainly can&#8217;t explain all of my examples by just saying &#8220;NULL is the empty set&#8221;.</p>
<p>> {NULL} != NULL (i.e. the set containing NULL != NULL alone)</p>
<p>If you do &#8220;SELECT * FROM foo WHERE NULL = NULL&#8221;, which NULL is &#8220;{NULL}&#8221; and which NULL is &#8220;NULL&#8221;? They look indistinguishable to me, but the predicate does not evaluate to TRUE.</p>
<p>> Does that help anyone?</p>
<p>I think that this line of reasoning will lead to mistakes. For instance, how do you explain the fact that COUNT(*) doesn&#8217;t ignore NULLs? Or that &#8220;x IS NOT NULL&#8221; is not the same as &#8220;NOT x IS NULL&#8221; for all x?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-95</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Fri, 14 Aug 2009 16:48:19 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-95</guid>
		<description>Why is it that no one seems to know that ...

NULL is the empty set.

All operations in SQL are based on set theory, not algebra as we normally consider it.  Set theory is the *basis* for (ordinary) mathematics and mathematical operations.  Set operations can appear to be very similar to &quot;normal&quot; mathematical operations, but since they may be missing key properties of that operation (say closure), they act in what appears to be a non-intuitive fashion.

So the definition of NULL is always consistent, it is the definition of operations over a set which may treat NULL elements in the set differently.

What is often the case is that what appears to be a case of ...
NULL == NULL
is really a case of ...
{NULL} != NULL (i.e. the set containing NULL != NULL alone)

For example, Aggregates often appear to be mathematical operations, like SUM(), but it is really defined as the operation over a set of elements which are either a number or elements convertible to a number.  And when converting a NULL to a number for the purposes of a &quot;SUM&quot;, it is easy to say that its number value is zero (which is the same as ignoring it).  Otherwise, SUM would be largely useless as an operation.

As such the SUM *operator* is not &quot;+&quot; it is a different (albeit similar) operator, and it inherently ignores NULL elements in the set in its computation.  It isn&#039;t inconsistent with &quot;+&quot;, because it was never meant to be the same as &quot;+&quot;.

Does that help anyone?</description>
		<content:encoded><![CDATA[<p>Why is it that no one seems to know that &#8230;</p>
<p>NULL is the empty set.</p>
<p>All operations in SQL are based on set theory, not algebra as we normally consider it.  Set theory is the *basis* for (ordinary) mathematics and mathematical operations.  Set operations can appear to be very similar to &#8220;normal&#8221; mathematical operations, but since they may be missing key properties of that operation (say closure), they act in what appears to be a non-intuitive fashion.</p>
<p>So the definition of NULL is always consistent, it is the definition of operations over a set which may treat NULL elements in the set differently.</p>
<p>What is often the case is that what appears to be a case of &#8230;<br />
NULL == NULL<br />
is really a case of &#8230;<br />
{NULL} != NULL (i.e. the set containing NULL != NULL alone)</p>
<p>For example, Aggregates often appear to be mathematical operations, like SUM(), but it is really defined as the operation over a set of elements which are either a number or elements convertible to a number.  And when converting a NULL to a number for the purposes of a &#8220;SUM&#8221;, it is easy to say that its number value is zero (which is the same as ignoring it).  Otherwise, SUM would be largely useless as an operation.</p>
<p>As such the SUM *operator* is not &#8220;+&#8221; it is a different (albeit similar) operator, and it inherently ignores NULL elements in the set in its computation.  It isn&#8217;t inconsistent with &#8220;+&#8221;, because it was never meant to be the same as &#8220;+&#8221;.</p>
<p>Does that help anyone?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Four short links: 6 August 2009 &#124; Design Website</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-92</link>
		<dc:creator>Four short links: 6 August 2009 &#124; Design Website</dc:creator>
		<pubDate>Mon, 10 Aug 2009 10:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-92</guid>
		<description>[...] What is the Deal with NULLs? &#8212; In the past, I&#8217;ve criticized NULL semantics, but in this post I&#8217;d just like to explain some corner cases that I think you&#8217;ll find interesting, and try to straighten out some myths and misconceptions. [...] I believe the above shows, beyond a reasonable doubt, that NULL semantics are unintuitive, and if viewed according to most of the &#8220;standard explanations,&#8221; highly inconsistent. (via bos on Delicious) [...]</description>
		<content:encoded><![CDATA[<p>[...] What is the Deal with NULLs? &#8212; In the past, I&#8217;ve criticized NULL semantics, but in this post I&#8217;d just like to explain some corner cases that I think you&#8217;ll find interesting, and try to straighten out some myths and misconceptions. [...] I believe the above shows, beyond a reasonable doubt, that NULL semantics are unintuitive, and if viewed according to most of the &#8220;standard explanations,&#8221; highly inconsistent. (via bos on Delicious) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-90</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Sun, 09 Aug 2009 18:05:57 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-90</guid>
		<description>&gt; #1 – Always add a not null constraint on all your fields when creating a table.

Unfortunately, I don&#039;t think that&#039;s a universal solution. (a) NULLs will be generated anyway, by outer join and aggregates; and (b) most SQL implementations don&#039;t effectively optimize physical designs that avoid NULLs, so there may be a significant performance penalty.

&gt; #3 – When you have a nullable field, go all over your client code and make sure you coalesce your comparisons, your strings concatenation, etc.

That&#039;s certainly good practice. When you have a query, look at any fields that can possibly be NULL, consider how those might affect your application differently, and handle them appropriately.

&gt; #5 – Never use null as a meaningful value. e.g. if you want to store the date value “infinite time in the past”, use the lowest date available in the system, not “null value”.

I think that&#039;s a good rule. Don&#039;t use NULL as an arbitrary &quot;special value&quot;</description>
		<content:encoded><![CDATA[<p>> #1 – Always add a not null constraint on all your fields when creating a table.</p>
<p>Unfortunately, I don&#8217;t think that&#8217;s a universal solution. (a) NULLs will be generated anyway, by outer join and aggregates; and (b) most SQL implementations don&#8217;t effectively optimize physical designs that avoid NULLs, so there may be a significant performance penalty.</p>
<p>> #3 – When you have a nullable field, go all over your client code and make sure you coalesce your comparisons, your strings concatenation, etc.</p>
<p>That&#8217;s certainly good practice. When you have a query, look at any fields that can possibly be NULL, consider how those might affect your application differently, and handle them appropriately.</p>
<p>> #5 – Never use null as a meaningful value. e.g. if you want to store the date value “infinite time in the past”, use the lowest date available in the system, not “null value”.</p>
<p>I think that&#8217;s a good rule. Don&#8217;t use NULL as an arbitrary &#8220;special value&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IT Security Blog&#187; Blog Archive &#187; delicious/cdman83</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-87</link>
		<dc:creator>IT Security Blog&#187; Blog Archive &#187; delicious/cdman83</dc:creator>
		<pubDate>Fri, 07 Aug 2009 15:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-87</guid>
		<description>[...] What is the deal with NULLs? [...]</description>
		<content:encoded><![CDATA[<p>[...] What is the deal with NULLs? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-86</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Fri, 07 Aug 2009 15:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-86</guid>
		<description>&gt; blankness, otherness, the dark void

I don&#039;t suppose you have an algebra of blankness, do you ? :)</description>
		<content:encoded><![CDATA[<p>> blankness, otherness, the dark void</p>
<p>I don&#8217;t suppose you have an algebra of blankness, do you ? <img src='http://thoughts.j-davis.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Davis</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-85</link>
		<dc:creator>Jeff Davis</dc:creator>
		<pubDate>Fri, 07 Aug 2009 15:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-85</guid>
		<description>&gt; NULLs are very logical

Can you point me to a specific algebra of NULLs, similar to the standard 2VL boolean logic algebra?

&gt; SQL is more sophisticated language, which makes it possible to write in one query the functionality that would require over 100 lines of code in Java

I am not at all suggesting that imperative languages like Java are a replacement for declarative languages like SQL. I am saying that SQL could be better by taking a different approach to NULLs specifically.</description>
		<content:encoded><![CDATA[<p>> NULLs are very logical</p>
<p>Can you point me to a specific algebra of NULLs, similar to the standard 2VL boolean logic algebra?</p>
<p>> SQL is more sophisticated language, which makes it possible to write in one query the functionality that would require over 100 lines of code in Java</p>
<p>I am not at all suggesting that imperative languages like Java are a replacement for declarative languages like SQL. I am saying that SQL could be better by taking a different approach to NULLs specifically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-83</link>
		<dc:creator>Warwick</dc:creator>
		<pubDate>Fri, 07 Aug 2009 00:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-83</guid>
		<description>hmm. i think null is conveniently different in diff circumstances. if it is any one &#039;thing&#039; then it would have to be a human concept, and one of blankness, otherness, the dark void, the something else other than is or is not. null is effectively the void filled by spirituality, androgyny, and in some older systems chr(20) to fill out the field length.</description>
		<content:encoded><![CDATA[<p>hmm. i think null is conveniently different in diff circumstances. if it is any one &#8216;thing&#8217; then it would have to be a human concept, and one of blankness, otherness, the dark void, the something else other than is or is not. null is effectively the void filled by spirituality, androgyny, and in some older systems chr(20) to fill out the field length.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NULL is not a value &#124; nullwert</title>
		<link>http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/comment-page-1/#comment-81</link>
		<dc:creator>NULL is not a value &#124; nullwert</dc:creator>
		<pubDate>Thu, 06 Aug 2009 19:52:42 +0000</pubDate>
		<guid isPermaLink="false">http://davisjeff.wordpress.com/?p=4#comment-81</guid>
		<description>[...] Ein kleines Stück Artikel, dass der Frage nach dem Sinn des Werts NULL im SQL-Standard nachgeht. Wer nicht weiss, wovon ich rede, braucht nicht weiterlesen &#8211; es hat rein gar nichts mit dem eigentlichen Thema des Blogs zu tun, &#8220;nur&#8221; mit meinem Beruf. Und meiner Vorliebe für logische Spielereien und die Grenzen der Logik. Und deshalb zum Teil mit dem Grund für die Namensgebung dieses Blogs.   [Translate]    English  العربية  Deutsch  español [...]</description>
		<content:encoded><![CDATA[<p>[...] Ein kleines Stück Artikel, dass der Frage nach dem Sinn des Werts NULL im SQL-Standard nachgeht. Wer nicht weiss, wovon ich rede, braucht nicht weiterlesen &#8211; es hat rein gar nichts mit dem eigentlichen Thema des Blogs zu tun, &#8220;nur&#8221; mit meinem Beruf. Und meiner Vorliebe für logische Spielereien und die Grenzen der Logik. Und deshalb zum Teil mit dem Grund für die Namensgebung dieses Blogs.   [Translate]    English  العربية  Deutsch  español [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
