MySQL Integer 0 vs NULL
Declare columns to be NOT NULL if possible. It makes SQL operations faster, by enabling better use of indexes and eliminating overhead for testing whether each value is NULL. You also save some storage space, one bit per column. If you really need NULL values in your tables, use them. Just avoid the default setting that allows NULL values in every column.
MySQL - optimizing data size
Using NULL
is preferable, for two reasons:
NULL
is used to mean that the field has no value, which is exactly what you're trying to model.- If you decide to add some referential integrity constraints in the future, you will have to use
NULL
.