7

I have some columns that may contain data that is if the user wants to provide it.

Example | Email | First Name | Last Name |

Email - Required so column is set to NOT NULL - Default: None

First Name - Not Required so column set to NULL - Default: NULL

Last Name - Not Required so column set to NULL - Default: NULL

In phpmyadmin when creating/editing a column; it has an option saying Default: with a drop down showing None | As Defined | NULL | Current Timestamp

Because First Name | Last Name is optional and not required should I choose default NULL or maybe NONE?

Which is best and why please?

I know there are many discussions on this already but I could not find any that answered my question; they was more in regards to allowing NULL or NOT NULL, my question is about default value.

halfer
  • 19,824
  • 17
  • 99
  • 186
PHPLOVER
  • 7,047
  • 18
  • 37
  • 54

3 Answers3

13

You should set them to Default:Null as if the user doesn't provide any info for that fields, they should be null obviously.

Hakan Deryal
  • 2,843
  • 1
  • 20
  • 19
7

Use NULL, None mode is inserting 'None' or some '' string to indicate that there is nothing there....

For more information why you want to use NULL versus a string look here: MySQL, better to insert NULL or empty string?

Community
  • 1
  • 1
Nix
  • 57,072
  • 29
  • 149
  • 198
0

If you are planning to index those NULL columns, you'll really get performance problems on big tables (with more than 1 million rows...). However, using an empty string or NULL as a string ('null') for a default value may increase your query performance on those cases. BTW, I'm not telling that NULL is evil, but those are some cases we've faced in telco business.

Cem Güler
  • 625
  • 12
  • 22
  • Thanks for the head up on that. I won't be indexing those columns with NULL values in so that should hopefully not be a problem for me. Thanks phplover – PHPLOVER Feb 28 '11 at 09:46