This is a discussion on sql within the SQL Server forums, part of the Microsoft SQL Server category; --> It's better to use "null" values or "0" and "" ? thank you...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| On Sun, 20 Jun 2004 10:20:35 +0200, Utopian [ FTa ] wrote: >It's better to use "null" values or "0" and "" ? > >thank you > Hi Utopian, You'll probably get different answers to this question. Many people advise against using NULLs, because some of the consequences of having NULL in a database are not well understood by many programmers. I think you should use NULLs to indicate missing information. If you combine attributes that are not directly related into one table, you must expect that there will be occasions that not all information can be stored (for whatever reason). Some people choose to store special values (like zero, the blank string or 1/1/1900) to indicate this, trying to avoid the "problems" they perceive with NULL. Instead, they only hide these problems, and add some extra problems to boot. An RDBMS comes with a special instrument to deal with unknown values. That special instrument is NULL. It's just silly to avoid this instrument and make up your own instead, just because some programmers don't understand how three-valued logic works. Much better would be to teach these programmers to do their job properly. Of course, regardless of whether unknown values are stored as NULL or as special values, it's always best to allow as little unknown values as possible. Best, Hugo -- (Remove _NO_ and _SPAM_ to get my e-mail address) |
| ||||
| >> It's better to use "null" values or "0" and "" ? << Where to start? Well, the double quote mean that you have a user created data element name; and NULLs are not values. I think that if you knew the bare foundations of SQL and a little grammar, you might have meant to post: >> Is it better to use NULLs, or to use 0 and ''? << Now the question is silly and not incoherent. Now we have NULL, a numeric zero and an empty string. The answer is "use for what?" Which is better- a screw or a basket ball? Does your application and data model require a value or a NULL? |