Jump to content


Photo

When to use the 'null' option


  • Please log in to reply
4 replies to this topic

#1 Rogue3

Rogue3
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 06 July 2006 - 12:54 PM

I have a field in my form (varchar(80)) that I don't always enter information for. It's an "additional keyword" field used to put additional keywords for my search form. Right now I have it to where it is just blank, but should I have it set to 'null' if there is no info there? Will this affect the search one way or the other?

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 06 July 2006 - 01:59 PM

it won't affect the search, really, but it may help in your queries to have it NULL as opposed to an empty string. they are not the same thing. an empty string still has memory allocated to store it, while a NULL is a truly empty value. setting your table to default NULL is usually a good idea.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 July 2006 - 04:21 PM

Having NULL-able fields make a big difference... use it only when you actually care about knowing that values where unspecified vs. blank.  Otherwise, it makes querying, indexing, joining, etc. more complicated.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 Rogue3

Rogue3
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 06 July 2006 - 04:27 PM

Well, the field that can sometimes be left blank is going to be a searchable field, but not a field that will display on the results page.

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 July 2006 - 04:59 PM

Doesn't matter what the public sees... it only matters if you need to know the difference.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users