Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:08:17+00:00 2026-05-24T00:08:17+00:00

Today, I’ve had some debate with my colleague about choosing data types in our

  • 0

Today, I’ve had some debate with my colleague about choosing data types in our projects.

We’re web developers and we code back-end in PHP, and for database we use mySQL.
So, I went on internet a bit, and they don’t recommend ENUM data type for various reasons (also I’ve read here on SO that this is not recommended) – For ENUM(‘yes’,’no’) for example you should use tinyint(1) .
If ENUMs are bad and should be avoided, why does vBulletin for example, uses them?
Why use them at all when you can use VARCHAR, TEXT and so on and enforce use of 1 of 2 possible values in PHP.
Thank you for your answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:08:18+00:00Added an answer on May 24, 2026 at 12:08 am

    Enums aren’t ideal, but they are waaaay better than your alternative suggestion of using a VARCHAR and enforcing one of a few possible values!

    Enums store their data as a numeric value. This is ideal for storing a field with a limited set of possible values such as ‘yes’ or ‘no’, because it uses the minimum amount of space, and gives the quickest possible access, especially for searches.

    Where enums fall over is if you later need to add additional values to the list. Let’s say you need to have ‘maybe’ as well as ‘yes’ or ‘no’. Because it’s stored in an enum, this change requires a database change. This is a bad thing for several reasons – for example, if you have a large data set, it can take a significant amount of time to rebuild the table.

    The solution to this is to use a related table which stores a list of possible values, and your original field would now simply contain an ID reference to your new table, and queries would make a join to the lookup table to get the string value. This is called “normalisation” and is considered good database practice. It’s a classic relational database scenario to have a large number of these lookup tables.

    Obviously, if you care fairly sure that the field will never store anything other than ‘yes’ or ‘no’, then it can be overkill to have a whole extra table for it and an enum may be appropriate.

    Some database products do not even provide an enum data type, so if you’re using these DBs, you are forced to use the lookup table solution (or just a simple numeric field, and map the values in your application).

    What is never appropriate in this situation is to use an actual string value in the table. This is considered extremely poor practice.

    VARCHARS take up much more disk space than the numeric values used by an enum. They are also slower to read, and slower to look up in a query. In addition, they remove the enforcement of fixed values provided by enum. This means that a bug in your program could result in invalid values going into the data, as could an inadvertant update using PHPMyAdmin or a similar tool.

    I hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I had a discussion with a colleague about nested functions in Javascript: function
Today we have received some strange exceptions on our production website. They all have
Today I discovered that something I had assumed about VB.NET for many years was
Today I was reading code from some very popular numerical libraries written in FORTRAN
Today I had a coworker suggest I refactor my code to use a label
Today at work we came across the following code (some of you might recognize
Today while I was writing some code for two methods that shows and hides
Today, I saw this article on Twitter about getting Webm data from a canvas:
Today I just had my first class on Java ee and dynamic web project...
Today at work, I was given a task to fix a bug within our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.