For example I have a checkbox beside the persons name on their profile settings page with the option to make this visible to the public or not.
Visible?
In my database I will have a variable called first_name_visible. what type should it be? Checkboxes return a the value (in this case “1”) if checked, and null if not.
MySQL does have BOOL and BOOLEAN data types, but they are synonymous with INT(1). So this is the type you would use with the possible values 0,1, or NULL.
1 would be true (checked).
0 would be false.
NULL should be considered NULL – no value entered. I would avoid using NULL to represent false. This allows you to better check your inputs and data integrity. In most cases I would set BOOLEAN columns to NOT NULL.