I’m putting together a MySQL database and the data is a list of customers. Not all of the fields for each customer has data. So some fields are empty. We hope to complete the missing data, but would like to be able to produce a report using SELECT to list those customer records which have missing data fields.
What should be stored in those fields until data can be updated to them? Should it be NULL? Empty? Or something else? Also, when setting up the MySQL TABLE what should the NULL column be set to and what should the DEFAULT column be set to to best handle those situations where there might not be data? Thanks!
NULLexplicitly means no data.So if you want to make sure that you mean it has no value, use
NULL. Otherwise, all other defaults are considered values.A blank string
''is a value.Zero
0is also a value.But
NULLis special as it means no value.It will make querying rows where nothing is entered easier.
You should still do type-checking for your data – so that people don’t enter
-1or0in a height or weight column. For us, its obvious – nothing can have0height, but to a database the column has a value – even if its illogical and you’ll have to adjust your queries to filter these rows.