I have created the following drop down for my front-end webpage:
<select>
<option value="All">All</option>
<option value="carer">Carer</option>
<option value="childminder">Childminder</option>
<option value="children_socialcare">Children Social Care</option>
<option value="creche">Creche</option>
</select>
I’ve set up the mysql database to have all the option values as fields:
Type=INT(1) Null=Yes; Default=Null
I have set these as integers as I’m copying in data from a word form where the select options are checkboxes.
mysql table:
mysql> family_support;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| carer | int(1) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
Although tideous is it okay to use integers in this way (not just for numeric values)?
I think the questions is: Should I use integers for saving boolean values?
Yes you should. I suggest to use
TINYINT(1) NOT NULL. Use the values 1 (TRUE/selected/checked) and 0 (FALSE/not selected/not checked).In newer MySQL releases you can use the the field type
BOOL/BOOLEAN, which is just an alias forTINYINT(1).See here: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html