-
To NULL or to not NULL
I want to open up this question to all my fellow VB.Net programmers. This question pertains to the "allow null" option in MS SQL Server and it's use or none use in a VB.Net app.
I have been struggling with the option of allowing null in some of my database fields, or setting a default value of space for my char type fields. Can I hear your thoughts of when to allow a null and when not to allow a null?
-
Lets say that you have a database full of customer information. Some information you do not have, like a few phone numbers or addresses. You can have those fields be null until you get the information that you need to fill them in.
So, you want to get all of this missing information, so you run a query to find all of the records that have null values. Using an email address that you have as a non-null field, you email all of the addresses that result from your query, asking them for the missing data.
That was the example that I remember from my database class. But that was a while ago. Also, why bother storing unnecessary data as a placeholder when you can just leave it null?
Hope that helps
Jim
-
null <> ""
Null means that you have yet to store the information, as yaksplat points out above.
whereas "" means you have stored the data but it is blank. So to expand on yaksplat analogy - the FaxNo field would contain Null until you asked the customer what their Fax no was - they replied that they didn't have a fax so you stored "".