473,545 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Defaulting ALL database columns in ALL tables - not allowing any NULL values...???

Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===
Thanks,
John.

Jan 23 '07 #1
8 3673
"DaFrizzler " <Da********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.com...
Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===
Thanks,
John.
Each nullable column uses one extra byte for the null indicator, so NOT NULL
WITH DEFAULT would save some storage. I don't know about the other claims
regarding performance and ease of backup/recovery.

What kind of advice or suggestions are you looking for?
Jan 23 '07 #2
Mark,

I am looking for exactly the kind of info/advise you just provided.
That is the first concrete reason I have received as to why this might
be a valid idea.

What is your opinion on using 0 as the default for numeric fields?

As far as I am concerned, 0 is a number in its own right, and there are
bound to be situations where we will want to indicate that there is no
value stored by using null. In a situation where 0 is a valid value,
how do you differentiate between the default value of 0 and a user
inputted value of 0?

The reason I am putting these questions out there is that I have never
come across the idea of defaulting every column on every table in a
database, and was wondering if anyone else has come across this
concept, or even better, worked with an implementation where this was
used.

Thanks,
John.


Mark A wrote:
"DaFrizzler " <Da********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.com...
Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===
Thanks,
John.

Each nullable column uses one extra byte for the null indicator, so NOT NULL
WITH DEFAULT would save some storage. I don't know about the other claims
regarding performance and ease of backup/recovery.

What kind of advice or suggestions are you looking for?
Jan 23 '07 #3
Mark A wrote:
"DaFrizzler " <Da********@gma il.comwrote in message
news:11******** *************@k 78g2000cwa.goog legroups.com...
>Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===
Thanks,
John.

Each nullable column uses one extra byte for the null indicator, so NOT NULL
WITH DEFAULT would save some storage. I don't know about the other claims
regarding performance and ease of backup/recovery.

What kind of advice or suggestions are you looking for?

DB2 has NULL as well as DEFAULT compression. AFAIK that does NOT require
the compression feature. So the benefit of NOT NULL columns may be less
than one might think.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jan 23 '07 #4
DaFrizzler wrote:
Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===
Mark and Serge already gave some arguments. I think, there are a few more
things to consider:
(1) If you get rid of the null indicators by always using NOT NULL, you save
some space (1 byte per row). However, each row where you would have a
NULL before will now _waste_ space because the actual value has to be
stored. Granted, default compression would reduce that again.
(2) I don't think that decisions like nullable/not-nullable should be left
to the DBA.
It is a design decision during application development. The application
developer are the only ones that know whether a nullable column makes
sense or is mandatory in certain situations.
As you already pointed out, there are sometimes no good defaults. Using
0 (zero) for numeric fields to represent NULL has a high chance of
clashing with the numerical 0.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 23 '07 #5
DaFrizller:

FWIW, I agree strongly w/ Knut: this is not merely a storage issue but
a design issue. As you may be aware, the whole NULL/2VL/3VL issue is
very prickly, and pros and cons for both allowing and disallowing NULLs
abound (flip over to comp.databases. theory if you'd like to read some
spittle-flecked rants on the subject). The issue is not merely bytes
but also of semantics.

OK--enough soapboxing. You asked about Hibernate. One issue I'm aware
of is that it's not enough to declare a DEFAULT in DB2; you must also
declare the (same) default value in the BO (.java file). If you do not,
you risk overwriting the database-written default with whatever value
is in the instance variable mapped to the database field (often NULL),
when the Java values are persisted.

--Jeff

Knut Stolze wrote:
DaFrizzler wrote:
Hi, I have received the following email from a colleague, and am quite
frankly baffled by the idea.

I am just wondering if anyone has any advice or suggestions about
this????
=== BEGIN MAIL ===
The DB2 DBA has requested that all columns in the tables be defined as
not null with default to improve storage, performance, and ease of
backup/recovery. Currently there are several columns in each table
that are nullable. By making these columns not null with default,
there would always be a value in the column, space for char/varchar,
and 0 for integer/smallint/decimal. Does this cause any problems with
the Java/Hibernate code? The DBA has indicated that all of the other
Java applications are defined this way.
=== END MAIL ===

Mark and Serge already gave some arguments. I think, there are a few more
things to consider:
(1) If you get rid of the null indicators by always using NOT NULL, you save
some space (1 byte per row). However, each row where you would have a
NULL before will now _waste_ space because the actual value has to be
stored. Granted, default compression would reduce that again.
(2) I don't think that decisions like nullable/not-nullable should be left
to the DBA.
It is a design decision during application development. The application
developer are the only ones that know whether a nullable column makes
sense or is mandatory in certain situations.
As you already pointed out, there are sometimes no good defaults. Using
0 (zero) for numeric fields to represent NULL has a high chance of
clashing with the numerical 0.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 23 '07 #6
Knut Stolze wrote:
Mark and Serge already gave some arguments. I think, there are a few more
things to consider:
(1) If you get rid of the null indicators by always using NOT NULL, you save
some space (1 byte per row). However, each row where you would have a
NULL before will now _waste_ space because the actual value has to be
stored. Granted, default compression would reduce that again.
(2) I don't think that decisions like nullable/not-nullable should be left
to the DBA.
It is a design decision during application development. The application
developer are the only ones that know whether a nullable column makes
sense or is mandatory in certain situations.
As you already pointed out, there are sometimes no good defaults. Using
0 (zero) for numeric fields to represent NULL has a high chance of
clashing with the numerical 0.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Maybe you have not worked as a DBA in a large application development
project, but the design of the database to support the business
requirements is usually defined by the data modeler for the logical
model and the DBA for the physical design (usually these are the same
person). Databases that are designed by developers (usually by
committee) are often times not very good in my experience (even though
I am a former developer).

I did not give any "arguments" in favor of not using nulls, I just said
that using nulls requires an extra byte for each nullable column (I
don't know about any native compression). However, I would find it hard
to believe that these extra bytes would be a real issue unless there is
an extremely large data warehouse being designed. But as noted, if the
requirements are to distinguish a null from a zero, then I would think
using nulls is justified in almost all cases.

Jan 23 '07 #7
Knut Stolze wrote:
(1) If you get rid of the null indicators by always using NOT NULL, you
save
some space (1 byte per row).
That should have been "1 byte per nullable value"
However, each row where you would have a
NULL before will now _waste_ space because the actual value has to be
stored. Granted, default compression would reduce that again.
(2) I don't think that decisions like nullable/not-nullable should be left
to the DBA.
It is a design decision during application development. The
application developer are the only ones that know whether a nullable
column makes sense or is mandatory in certain situations.
As you already pointed out, there are sometimes no good defaults.
Using 0 (zero) for numeric fields to represent NULL has a high chance
of clashing with the numerical 0.
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 24 '07 #8
Mark A wrote:
Maybe you have not worked as a DBA in a large application development
project, but the design of the database to support the business
requirements is usually defined by the data modeler for the logical
model and the DBA for the physical design (usually these are the same
person).
I totally agree. A good data modeler also knows about NULLs, their
semantics, and where they can and should be used and where not.
Databases that are designed by developers (usually by
committee) are often times not very good in my experience (even though
I am a former developer).
I'm not arguing against that. ;-) I prefer to have _one_ _knowledge_
person, who is aware of logical and physical design, responsible for the
overall database design. A general statement like "use NOT NULL everywhere
and all the time" just raises some eyebrows, that's all.
I did not give any "arguments" in favor of not using nulls,
Right - I omitted the "in favor" or "against" part for a good reason... ;-)
I just said
that using nulls requires an extra byte for each nullable column (I
don't know about any native compression). However, I would find it hard
to believe that these extra bytes would be a real issue unless there is
an extremely large data warehouse being designed. But as noted, if the
requirements are to distinguish a null from a zero, then I would think
using nulls is justified in almost all cases.
Same thing with NULLs and empty strings: They are logically different things
and sometimes should not be thrown together.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 24 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
5636
by: madsgormlarsen | last post by:
Hi I need to test a field(colum) in a SQL database for for NULL values, and have done so in this way. $query = "SELECT j FROM Andersen"; $result = mysql_query($query, $link_id); $query_data = mysql_fetch_array($result); if (array_sum($query_data)==0) {
5
6046
by: JackT | last post by:
Hi, I have the following SQL SELECT Table1.Col1, Table3.Col1 AS Expr1, COUNT(Table1.Col2) AS Col2_No, COUNT(Table1.Col3) AS Col3_No etc, FROM Table3 INNER JOIN Table2 ON Table3.Col1=Table2.Col1 RIGHT OUTER JOIN Table1 ON Table2.Col2=Table2.Col2 GROUP BY Table1.Col1, Table3.Col1
5
2777
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new columns and then copy all of the data across. As far as I am aware when you add a DEFAULT column the following happens:
1
1608
by: serge | last post by:
How can i enter Default Values of " " to all the columns of type character of all the tables (excluding system tables) and Default Values of 0 of all columns of type numbers. Excluding all primary key columns. Thank you
2
28537
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
4
3205
by: JohnR | last post by:
Hi, I'm trying to update a DBF file which I'm using VB.NET ODBC adapters, commands and connections. I fill the dataset and databind the columns to textboxes on my form. I can successfully view, delete and update the records. The problem is when I try to add a new record. Because I actually have a few controls bound to the same table I use...
4
2269
by: onecorp | last post by:
I have a SQL table comprised of 31 columns. The first column is simply an id column, the next 30 columns are labelled ,.... The numerical columns have a tinyint type and the data stored is either 1 or null. I wish to count the number of times a one appears in one column simultaneously with another column: eg count the number of times 1...
4
1645
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block...
3
3403
by: mturner64 | last post by:
I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input (first name, last name, donation amount and date). After the user inputs the values, I want them to click the "Submit" button and have that...
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.