Sign in
Log inSign up

Database field enum kind of type

P Ξ D R O L U Z 🐿's photo
P Ξ D R O L U Z 🐿
·Jul 10, 2016

Hi,

For those you have experience with databases for big data (RDBMS), I have a question what is on the back of my head for a long time.

If you have a table called user with a status field, do you prefer for it to be (or the best in terms of performance) to be defined:

`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '0=blocked,1=active,2=dead'

or: status VARCHAR(20) NOT NULL DEFAULT 'blocked' COMMENT 'blocked,active,dead',

Of course you can still have a relation to another table where you have those status defined. But in this case is not important.

Personally I've been always a big fan of the first one.

Between these two what is better in terms of performance? The db that I'm using is MySQL 5.7, but this is more like a generic RDBMS question.

Or actually use ENUM() ?

Thanks