patternsqlMinor
What data type should I use: ENUM, TINYINT, or CHAR?
Viewed 0 times
tinyintwhatenumchartypeshouldusedata
Problem
I'm creating a new table and I would like to do it right. The table will be a list of members with their Professional Type and Decile associated.
The Professional Type is a 3-character string. There are only 8 allowable strings for this field. Should I use ENUM or CHAR(3) or something better?
The Decile can be any number between 1-10, but only these numbers. Should I use ENUM or unsigned TINYINT or something better?
Which are the best options for efficiency?
The Professional Type is a 3-character string. There are only 8 allowable strings for this field. Should I use ENUM or CHAR(3) or something better?
The Decile can be any number between 1-10, but only these numbers. Should I use ENUM or unsigned TINYINT or something better?
Which are the best options for efficiency?
Solution
ENUMs scare me because of any issue regarding adding/removing type values. You are probably better off representing both
See my past posts on
For efficiency, please do not index this field alone, given such a low cardinality (8,10).
ProfessionalType and Decile as TINYINT or CHAR(3). Anything but ENUM.See my past posts on
ENUM :Ocy 19, 2011: Advantages and Disadvantages to using ENUM vs Integer types?
Jan 24, 2012: Is it possible to change ENUM() lists?
For efficiency, please do not index this field alone, given such a low cardinality (8,10).
Context
StackExchange Database Administrators Q#40248, answer score: 5
Revisions (0)
No revisions yet.