I have a Address table
in my mySQL database with some fields.
On my form i ask a user to input values for these fields. But the street field is not required
. So when my form gets submitted my Column Street is just empty in my database. This works fine and gives no errors without setting the column to accept NULL .
So my question is :
What is the benefit of setting the Street column to nullable?
Example migration (Laravel) without nullable:
$table->string('street');
Example Migration with nullable
$table->string('street')->nullable();
Both work fine .
user_id
foreign key on youraddress
table and for some reason you have an address you need to store which doesn't belong to auser
, you'd be able to set thatuser_id
column to null and it should still work without violating the foreign key constraints where an empty space would. – user1669496