*solved* when to use NULL and when not to
Posted 01 September 2006 - 04:28 PM
Posted 01 September 2006 - 04:38 PM
You obvisouly want to store the posters name and email address in the database so you make those fields not null. However for the webpage field you'll make that field NULL. As not everyone may have a website.
Thats one example of use of setting a row to null.
Null means whether the field can have a null value, meaning you are able to store nothing in that field. not null doesnt allow to store nothing in the field. So basically use NULL on a field when a field is not required to have a value when inserting data in to the database.
Posted 01 September 2006 - 04:51 PM
For example, it's silly to have a NULLable gender column, since everyone has a gender, so blank (empty column) is just as good as male/female. However, if your storing, say, how many children someone has, you need to be able to distinguish between "0" (no children) and no answer (unknown #).
Hope that makes sense.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users