[dba-SQLServer] NULLs

Asger Blond ab-mi at post3.tele.dk
Sun Mar 15 18:23:33 CDT 2009


Coming in late I have a few comments here.
1. In SQL Server you can make indexes on NULL allowed columns, and the
engine sure will use these indexes if they are useful for the queries.
2. The column order of NULL allowed columns is of no importance in SQL
Server as it maintains header information for each row telling if NULL
allowed columns have a value or not.
3. And Arthur: "obviously I forbid them in any FK column". Don't agree,
seems quite allowable to me. Imagine you have a Department and an Employee
table. Your Employee table has a FK referencing the Department table. Now
you just hired a new employee but haven't decided yet the department for the
employee. Isn't it reasonable to make a record for the new employee leaving
the FK column NULL? 

Asger

-----Oprindelig meddelelse-----
Fra: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af Arthur
Fuller
Sendt: 14. marts 2009 17:13
Til: Discussion concerning MS SQL Server
Emne: [dba-SQLServer] NULLs

Over on the MySQL group, a discussion has been waging about the use of
NULLs. One guy in particular is adamant about forbidding them everywhere. He
goes so far as to say the existence of NULLs means bad design, pure and
simple. I am not quite so radical about it, but I do look askance at any
column that permits them, and obviously I forbid them in any FK column.

I tossed that in just to take the pulse of this group on this general topic,
but my real question concerns something one of the posters wrote:

"It seems that someone got bitten very hard in a soft area by a Null one
day.
On a more practical level, Oracle recommended to design the table with the
field where NULLs are to be expected at the end of the table, that saves a
little space and two, as the use of indexes is invalidated in case of nulls
its is better to place the important indexed fields toward the beginning of
the table."

I don't know whether this is also true of SQL Server. Do you?

Arthur
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com






More information about the dba-SQLServer mailing list