ENUM or Boolean?

Asked

Viewed 245 times

1

I have a table NOTICIA and in it I have a column ATIVO

The news may be active or not, if it is BOOLEAN (0 or 1) if ENUM (ACTIVE OR NON-ACTIVE) .

Which one would be better to use, BOOLEAN or ENUM ?

2 answers

3

Since Mysql 5.0.3 you have the type BIT(quantidade de bits) which may be used in such cases, if specified BIT(1).

Boolean is just one alias for TINYINT(1).

Enum as its name already says, it is for enumerations, ie a list of values "named", internally is stored as number, turns out to be no better than and the Boolean internally.

Some links that might interest you about these types:

What is the difference between SET and ENUM in Mysql?

BIT(1) versus TINYINT(1) for boolean values

-5

I suggest never using BOOLEAN in tables, because it is routine to appear a posteriori requirements that require more than two states. Use ENUM or even a simple INT.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.