My requirement
A table needs to maintain a status column.
This column represents one of 5 states.
initial design
I figured I can just make it an integer column and represent the states using a numeric value.
- 0 = start
- 1 = running
- 2 = crashed
- 3 = paused
- 4 = stopped
Since I don't want my app to maintain the mapping from the integers to their string description, I plan to place those in a separate state description table (relying on a FK relation).
Then I discovered that MySQL has an ENUM type which matches my requirement exactly.
Other than a direct dependency on MySQL, are there any pitfalls with using the ENUM type?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…