Re: So what's null then if it's not nothing?

From: <michael_at_preece.net>
Date: 30 Nov 2005 22:37:28 -0800
Message-ID: <1133419048.763614.288480_at_g43g2000cwa.googlegroups.com>


Jon Heggland wrote:

> In article <1132912144.091433.13610_at_z14g2000cwz.googlegroups.com>,
> michael_at_preece.net says...
> > > Ok. Let's say that the empty string can be called "no value at all" for

> > > a text variable. What is "no value at all" for an integer variable?
> > > --
> > > Jon
> >
> > Well Jon - I'd say they're both NULL. NULL is type-less.
>
> That is a bit troublesome if you like strong typing, as I do. But let
> that pass.
>

I'm sure the standard says NULL is type-less - or words to that effect. Maybe it's more along the lines of every data type must allow NULL.

> > In the case of
> > "no value at all" for an integer variable we can't store an empty
> > string so we would store NULL.

>
> I wonder a little how you can say you can store NULL, but not the empty
> string, in the integer variable.

Well - in Pick, where everything is essentially a string, there's no problem. In other environments with strong typing then an empty string would be an option I suppose. I just assume it would be less problematic in those environments to use a special character - like char(0) say.

> If NULL is typeless, and "" is the same
> as NULL, surely "" is typeless too? What is the logical difference
> between decreeing that any variable can be NULL, and that any variable
> can be "", regardless of type? But let that pass.
>

I have to run now... will continue this later, hopefully...

Cheers
Mike.

> > I know a lot of educated people will
> > tell me that NULL, when compared to any other value, results in
> > Unknown.
>
> If we're talking SQL, probably. Alternatively, it results in NULL, which
> may or may not be something other than Unknown. But let that pass.
>
> > I'd agree - if I agreed that NULL was unknown - or missing -
> > or absent - or not, in fact, data. I believe that NULL is, correctly,
> > "no value at all".
>
> I don't understand this discussion. The behaviour of NULL in SQL is
> pretty well-defined, although it can be discussed how consistent and
> intuitive it is. But I can't see how it can be possible to have an
> objective definition of what it *means*. Unknown, missing, absent, "no
> value" are not mutually exclusive to me; neither are they really
> comparable. A value can be missing *because* it is unknown, no? And
> isn't "absent" and "missing" synonymous, and don't they imply that there
> is no value? My gut feeling is that the DB designer should specify what
> hir NULLs mean in each table. In fact, that should be done for all
> attributes, regardless of whether they allow NULLs or not. But let that
> pass.
>
> My question is this:
>
> You say the empty string is the same as "no value at all", and say we
> should call this concept of "no value at all" NULL for other data types.
> Now, the empty string is a perfectly normal string. You can do string
> operations on it: concatenate it, find its substring, find its length
> and so on. For an integer variable that is NULL, it is very different.
> You cannot do integer operations on it; you cannot add it to another
> integer, or multiply it, for example.
>
> Doesn't this bother you? That for string variables, your NULL is just
> like any other string, but for integers (and all other types I can think
> of at the moment), it is something very peculiar?
> --
> Jon
Received on Thu Dec 01 2005 - 07:37:28 CET

Original text of this message