View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:43 PM
Simon Hayes
 
Posts: n/a
Default Re: To Null or not to Null that's my question


"A.M. de Jong" <arnojo@wxs.nl> wrote in message
news:boiskh$kr5$1@reader08.wxs.nl...
> Reading a lot about Nulls right now I still can't find a Technical reason

to
> use it or not.
>
> For what I've understand is this:
>
> In an Ingres database a Null column has a standard extra storage of 2

Bits.
> In a SQL Server database every column has a NULL-bit telling about this
> column it is NULL or NOT.
> That means that a varchar-empty NULLABLE column takes no space at all

since
> the Nullable column defines it as NULL.
> In that respect: When a lot of varchar columns tend to be empty from the
> space point of view make it NULLABLE.
>
> A varchar not nullable column must be filled with a '' when it's empty.

That
> single quote takes 3 bits since a varchar has an overhead of 2 positions.
>
> I am not talking about key-values although sometimes you see
> reference-columns to a Master table wich is emtpy (NULL in my case)
> Since the master table had no NULL-key item there is no Inner join

facility.
> I don't think SQL likes the outer join that much so it's clear to create

an
> UNKNOWN reference to the master table.
> (And place this Unknown item in the master table as well).
>
> But the rest: When should I use nulls and when do I do not ???
>
> Arno de Jong, The Netherlands.
>
>


Use NULLs when your data model requires it - that's much more important than
the physical storage requirements (at least for most people). In general, if
the column is an optional attribute, then use NULL; if the attribute is
optional but there is a sensible default available, use NOT NULL with a
DEFAULT constraint; if the attribute is not optional, it should be NOT NULL.

For more information, you might want to search for newsgroup postings by Joe
Celko, and his book "SQL for Smarties" discusses NULLability in some detail.

If you have a specific implementation issue related to NULL/NOT NULL,
perhaps you could give more details (including table DDL), and someone may
be able to point you in the right direction.

Simon


Reply With Quote