NULLs

Questions and answers regarding general SQL and backend databases

NULLs

Postby Morley » Wed Apr 21, 2004 4:32 pm

NULL terminology is not in familiar use for me and in a number of places in the Developer User's Guide confusing statements. The most prominent is on page 43: "In most SQL databases an empty value is something different from a NULL value (not existing)".

I've always assumed the condition of emptiness is the same as a NULL, therefore a field with a zero is NOT null. That to say a field is NULL is another way of saying it's empty.

The above quote is therefore confusing. If an empty field is not a NULL, then what's an example of a NULL?
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby maarten » Wed Apr 21, 2004 4:42 pm

Think of NULL as a field that has never had any entry.*

Think of an empty value like:
Entering a character in a field and hitting backspace again.
(the field now has an "empty value")

*columns/variables can be erased to NULL again by doing columnname=null
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

NULLs

Postby Morley » Wed Apr 21, 2004 5:01 pm

maarten wrote:Think of NULL as a field that has never had any entry.*

Think of an empty value like:
Entering a character in a field and hitting backspace again.
(the field now has an "empty value")

*columns/variables can be erased to NULL again by doing columnname=null


Then what's the significance and utility of NULLs? You're equating NULLs to virgin fields. I can't think of an example when this condition would have an advantage to know.

On page 100, creating columns in a table there's an option to allow or not allow nulls. Only the the serial number field "companyid" is turned off, which makes sense since it's automatic. I'm puzzled why the condition of nullness is not automatic according to the presence of auto enter features. If one were to uncheck a field to not allow it to be NULL and then didn't provide a means to fill it with something, an error would surely be created.

Also puzzled by the mixing of "Column" and "Field" in differing contexts, likewise "Row" and "Record". Is there a significant difference between these terms or are they equivalent?
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby maarten » Wed Apr 21, 2004 5:48 pm

Also puzzled by the mixing of "Column" and "Field" in differing contexts, likewise "Row" and "Record". Is there a significant difference between these terms or are they equivalent?

Check out the Servoy manual (F1) Getting started>Servoy concepts.
This will give you clear understanding.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby maarten » Wed Apr 21, 2004 5:56 pm

Then what's the significance and utility of NULLs? You're equating NULLs to virgin fields. I can't think of an example when this condition would have an advantage to know.

One simple example:
A null value is not the same as "zero" or "blank." NULL means no entry has been made, and usually implies "value unknown" or "value not applicable." It indicates that the user did not make any entry, for whatever reason. For example, a null entry in the price column of the titles table does not mean that the book is being given away free, but that the price is not known or has not yet been set.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby ve3cnu » Tue Jul 06, 2004 8:59 pm

I can't think of an example when this condition would have an advantage to know.


SInce NULL really means "unknown" it is important to know this for comparison reasons.

Where the length of an empty string is zero this is not true of NULL. The length of NULL is NULL. In fact any operation on NULL equals NULL.
ve3cnu
 
Posts: 13
Joined: Tue Jul 06, 2004 7:45 pm

Postby Morley » Tue Jul 06, 2004 10:40 pm

ve3cnu wrote:SInce NULL really means "unknown" it is important to know this for comparison reasons.

Where the length of an empty string is zero this is not true of NULL. The length of NULL is NULL. In fact any operation on NULL equals NULL.


Which explains some of the error messages I've been getting here and there. That's a subtle difference. There more levels of precision in Servoy/SQL than I've previously even considered.

Thanks for the tip.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 31 guests

cron