Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should booleans be NOT NULL in mysql?

In designing my database I realized I left some booleans as NOT NULL and others default to NULL. What is the rule of thumb for when to allow a boolean to be nullable? As the booleans I have are all is_SOMETHING, I'm thinking they should never NULL as they are either classified as the SOMETHING or not.

like image 805
WildBill Avatar asked May 28 '14 18:05

WildBill


1 Answers

A NULL boolean has three possible values: true, false, and null. A NOT NULL boolean has only two, true and false. Your application logic will have to suffice for telling you which is the correct choice.

like image 137
Tripp Kinetics Avatar answered Sep 30 '22 05:09

Tripp Kinetics