Reputation: 1143
I'm wondering what would be the best and most efficient way for storing simple data in the database. For example, say I have a column in my table called status with values such as complete, incomplete, won't complete, etc. Should I just store these values as is in the database?
Or should I store the values as 0, 1, 2 and have a php function like get_status to convert the number to the words?
Or should I store the values as 0, 1, 2, etc. and have another table that holds the string values, although this would require you to join to this table every time you need to know the value.
Upvotes: 0
Views: 240
Reputation: 54306
You could consider an enum
type. An enum
is a defined list of possible string values, e.g:
create table stuff (status enum ("foo", "bar") not null);
Upvotes: 0
Reputation: 3181
An enum column will work just fine.
http://dev.mysql.com/doc/refman/5.0/en/enum.html
Upvotes: 3