B
B
BonBon Slick2017-03-18 02:44:41
MySQL
BonBon Slick, 2017-03-18 02:44:41

Which is better to use enum() or boolean() field type?

If there are more than 3 statuses, then it is clear that enum should be used, but what are the differences if there are only 2 statuses? What type of field is preferable to use?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
ThunderCat, 2017-03-18
@BonBonSlick

Depends...
If it is really logical fields ala is/is not present it is possible to use bool. If these are just 2 values ​​clearly not related to true / false, it is better to use enum, especially if later the logic may change and you need to change the type.

A
Andrew, 2017-03-23
@iCoderXXI

I am using tinyint.

D
DM99, 2018-07-04
@DM99

if the answer options are "yes" and "no", then a boolean type is fine, if there is something akin to "white" and "black", then I would rather use an enum...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question