The author suggest never use NULL to store empty values in the database, I know I need to set some column type to NULL such as date and datetime but what about the rest?
The problem with using empty is: if I need to execute a insert query from PHP I need to create some dummy empty variables to be added to the query even if I don’t need to insert them.
It is Depending upon the variation of the Field’s width. If it is a fixed then it will take the same space as the width of the field.
Otherwise no space is taken up by NULL. However one bit is used to check the value of column is NULL or not.
I’m not entirely sure what the article’s point is.
They seem to be railing against using NULL’s because… you can’t do a LEN() against them? I’m not sure what use case he’s trying to point at in which NULL requires especial effort.
Yes, you should be aware that NULL and “” are not the same thing. But that’s not a reason to never use NULL’s, and its the same thing in multiple languages - undefined is not the same as “” in javascript, PHP, etc… In fact, most if not all database engines can easily dismiss this problem by simply specifying your WHERE clause properly in your select query. WHERE field IS NOT NULL.
Hi and thanks for your replies, I think will set for each column in the database the default to null so I will not have problems with storing empty fields in the database and mysql will take care of them