TEXT and NULL...

Started by Egon Sommeralmost 24 years ago3 messagesgeneral
Jump to latest
#1Egon Sommer
Service@Sommer-Maschinenbau.de

Hallo all,

Does it make any difference to save "no data" in a column with type TEXT or BYTEA as "" (empty string) or null?
Is one of it faster or more wast of memory?

Regards,
J�rg Sommer

--------------------------------------------------------------------------
Sommer Maschinenbau
Pagenstecherstr. 146
49090 Osnabr�ck

0049 (0)541 125085
0049 (0)541 129557

Service@Sommer-Maschinenbau.de
--------------------------------------------------------------------------

#2Herbert Liechti
Herbert.Liechti@thinx.ch
In reply to: Egon Sommer (#1)
Re: TEXT and NULL...

On Mon, 17 Jun 2002, Egon Sommer wrote:

Hallo all,

Does it make any difference to save "no data" in a column with type TEXT or BYTEA as "" (empty string) or null?
Is one of it faster or more wast of memory?

Always store NULL instead of empty strings. This will it make much
more easier in programming where you don't have to bother about
two conditions (NULL and empty string). An empty string on the
other hand may be a value in an application context where NULL is per
definition always the same. Storing NULL values is a good feature
of DBMS so use it ;-) Querying NULL values is part of the SQL-Syntax.

Best regards
Herbie

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti http://www.thinx.ch
ThinX networked business services Adlergasse 5, CH-4500 Solothurn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#3Dan Weston
ddweston@cinesite.com
In reply to: Herbert Liechti (#2)
Re: TEXT and NULL...

Whether storing NULL values in a relational database is a good idea is at
best highly contentious. Chris Date, one of the pioneers of relational
database theory, rejects them outright as a violation of the relational
model. You might want to check out one of his books and then make up your
own mind.

One thing that an empty string has going for it is that "" = "", and
nothing else does, whereas NULL is not equal to null (and is not even a
value).

Food for thought...

Dan Weston

On Mon, 17 Jun 2002, Herbert Liechti wrote:

Show quoted text

On Mon, 17 Jun 2002, Egon Sommer wrote:

Hallo all,

Does it make any difference to save "no data" in a column with type TEXT or BYTEA as "" (empty string) or null?
Is one of it faster or more wast of memory?

Always store NULL instead of empty strings. This will it make much
more easier in programming where you don't have to bother about
two conditions (NULL and empty string). An empty string on the
other hand may be a value in an application context where NULL is per
definition always the same. Storing NULL values is a good feature
of DBMS so use it ;-) Querying NULL values is part of the SQL-Syntax.

Best regards
Herbie