blog’s amazing Rotating Header Image

Why You Should Replace ENUM With Something Else

There are many developers who prefer using ENUM in MySQL, which seems to be a viable choice many times. However it’s important to take care as…

  • ENUM requires a rebuild of the table when adding a value to the middle of the set.
  • ENUM values are ordered in the order they’re added to the database
  • ENUM values do in the database what should be done in the model.

ENUM could be useful for columns that had data that would always fit into one particular set of values. For example gender would be one such field that might be served well with an ENUM.

As Brandon says: “The bottom line is that ENUM has its place, but should be used sparingly. The model should enforce the constraints, not the database; the model should handle interpreting raw data into useful information for your views, not the database.”

via Why You Should Replace ENUM With Something Else – Brandon Savage

Bookmark and Share

Leave a Reply