views:

139

answers:

4

Duplicate: http://stackoverflow.com/questions/163434/are-nulls-in-a-relational-database-okay

I dodged a heated debate concerning nulls in the database today. My opinion is that null is an excellent indicator of unspecified values. Every one else in the team, that has an opinion, thinks zero and empty strings are the way to go.

Are they lazy or am I to strict?

+9  A: 

They are lazy and do not understand the basic idea of a null in the database. Nulls are useful and have a purpose. They should neither be avoided nor used inappropriately.

Adam Robinson
Cyberherbalist
+3  A: 

null means no value while 0 doesn't, if you see a 0 you don't know the meaning, if you see a null you know it is a missing value

I think nulls are much clearer, 0 and '' are confusing since they don't clearly show the intent of the value stored

SQLMenace
exactly - abscence of data is not the same as default data
annakata
A: 

Surely if its unspecified then null is a good indicator, zero means something whereas null doesnt. I'm no expert DB though..

Charlie
A: 

Despite the extra work that using nulls requires I think there SHOULD be a difference between a non specified field and a field set to empty or 0.

Who else will you be able to say that a user set the value 0 on purpose or if he didn't set the field?

Sergio