If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Choosing NOT NULL fields

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-05, 14:24
Luc4 Luc4 is offline
Registered User
 
Join Date: Dec 2005
Posts: 7
Choosing NOT NULL fields

Hi. I'm attending a databse designing course and I have a doubt writing the physical structure (I'm using MySQL). I can't understand how to choose to put or not the NOT NULL constrain. I mean, is there a particular reason or is it only a choosing whether a field has to be completed or not? On which basis do you decide to put it or not?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-09-05, 14:39
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
That's basically it. If the field needs to have a value, then set it to NOT NULL.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #3 (permalink)  
Old 12-09-05, 15:03
Luc4 Luc4 is offline
Registered User
 
Join Date: Dec 2005
Posts: 7
The strange thing I can't understand is this: when I've been taught how to design the conceptual structure of the database, I learned to use fields with multiplicity. If I wanted a field to be "optional", I would have used a multiplicity (0,1) for instance. So, my doubt: why could I want to allow a field to be NULL? I mean, if I wanted to allow it to be NULL, I should have used a multiplicity (0,1). Maybe it was only a stupid doubt.
Thanks for your answer.
Reply With Quote
  #4 (permalink)  
Old 12-10-05, 11:17
ByteRyder52 ByteRyder52 is offline
Registered User
 
Join Date: Feb 2005
Location: Colorado Springs
Posts: 222
Another issue with NULL values is not to use them on key fields.
Reply With Quote
  #5 (permalink)  
Old 12-13-05, 10:40
pazpower pazpower is offline
Registered User
 
Join Date: May 2003
Posts: 13
Not Null Recommendations:
• In general, always use the not null option for a column if business data always exists.
• When using "not null with default" option, the default value may be
1) user-defined, or
2) system-created. The default value has to have a clear business meaning, in either case.

Null Recommendations:
• Use the null option for a column only if business data is not available or not applicable to the columns, particularly columns with date or numeric data types.
• When implementing Relational Integrity, foreign keys should not be implemented as "not null with default" unless the default value appears in the related table. If the foreign key may be nullable, it is preferable not to use "not null with default".
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On