I'm fairly new to MySQL and have been messing around with simple databases for about a year now using phpMyAdmin etc.
But one thing that's always puzzled me is the behaviour of setting fields to allow Null values and setting a default.
At the moment what I usually do is have all my fields set to not allow Null values - NOT NULL
Even if there are certain fields that I wish to remain empty.
When setting the field type as VARCHAR, phpMyAdmin sets the default value for that field as empty anyway.
Obviously with the INT type it sets the default as 0.
Is this the correct way of doing things?
For example I have a MySQL database containing names and addresses with the following fields...
Code: Select all
id
contact_name
company_name
address1
address2
address3
town_city
county_state
postcode_zip
countryBut most records don't have the address2 or address3 fields filled in, they're just blank / empty.
Is this the best way?
Or in my PHP script should I be setting those fields as NULL rather than putting an empty value?
Thanks
Ben