title: MySQL: Enum vs Varchar-with-Index
body: <p>Suppose, I have a requirement to create a table where one of the column will be having a value from this limited and never-changing set: 
  'all', 'local', 'qa', 'staging', and 'production'.</p>
  
  <p>Using <code>enum</code> data type for this situation looks like a suitable solution but after reading <a href="http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/" rel="nofollow noreferrer">this article</a> and some other threads on the internet, I feel discouraged to use it. So, if I do <strong>not</strong> want to create a lookup table <strong>and</strong> keeping the combination of <code>evn</code> and <code>name</code> unique is also a requirement then what is my best options between a column with ENUM type and a column with VARCHAR type but with an index created on it.</p>
  
  <p>Also considering that the insertion in this table will be rare and we want this particular query to execute faster:</p>
  
  <pre><code>SELECT `enabled` FROM `features`
  WHERE `name` = 'some_featuere'
  AND `env` IN('all', 'qa')
  ORDER BY `enabled` ASC limit 1;
  </code></pre>
  
  <p>Which one of these is a better design and why?</p>
  
  <pre><code>CREATE TABLE `features` (
    `id` INTEGER  NOT NULL AUTO_INCREMENT,
    `name` VARCHAR (50) NOT NULL,
    `env` ENUM('all', 'local', 'qa', 'staging', 'production') NOT NULL,
    `enabled` TINYINT(1) DEFAULT 0,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  
    PRIMARY KEY (`id`),
    UNIQUE KEY `idx_unq_features_name_env` (`name`,`env`)
  );
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>CREATE TABLE `features` (
    `id` INTEGER  NOT NULL AUTO_INCREMENT,
    `name` VARCHAR (50) NOT NULL,
    `env` VARCHAR(10) NOT NULL,
    `enabled` TINYINT(1) DEFAULT 0,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  
    PRIMARY KEY (`id`),
    INDEX `idx_features_env` (`env`),
    UNIQUE KEY `idx_unq_features_name_env` (`name`,`env`)
  );
  </code></pre>