TonyGroves
Programmer
Does anybody out there have any advice as to the best way to store a non-null boolean field? I have tried the following, but none are really satisfactory:
ENUM('0','1') NOT NULL
Problems: there are three possible values ('0', '1', ''), and a '0' value in numeric context evaluates to 1!
ENUM('1') NOT NULL
Problem: the default value is '1' (any other specified default is rejected).
ENUM('1')
Problem: there are three possible values (NULL,'1','').
TINYINT(1) UNSIGNED NOT NULL
Problem: it's not obvious that it's a boolean field, and there are 256 possible values.
Until a month ago, my database was using Paradox tables, which support a BOOLEAN type with values FALSE and TRUE; it's a pity MySQL hasn't got something similar.
ENUM('0','1') NOT NULL
Problems: there are three possible values ('0', '1', ''), and a '0' value in numeric context evaluates to 1!
ENUM('1') NOT NULL
Problem: the default value is '1' (any other specified default is rejected).
ENUM('1')
Problem: there are three possible values (NULL,'1','').
TINYINT(1) UNSIGNED NOT NULL
Problem: it's not obvious that it's a boolean field, and there are 256 possible values.
Until a month ago, my database was using Paradox tables, which support a BOOLEAN type with values FALSE and TRUE; it's a pity MySQL hasn't got something similar.