johnsmith153 Posted July 28, 2011 Share Posted July 28, 2011 Imagine a simple form where you submit name and hair color (example). You want them to select from brown, black and blonde hair color only. How would the db be setup? I'm thinking assign a number (1) brown, (2) black and (3) blonde and only store the number in the db. Is this the best way? What are the alternatives. I've seen people store the full colour name in the db. Thanks. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 28, 2011 Share Posted July 28, 2011 well, if you only store 1,2 and 3, then somewhere (another table, a text file, an array) you'll have to have the translation of each number into a color. Not worth it in this case, I would just store the actual colors in the database. Makes it easier if later (say two or 3 years from now) you look at the database and can't remember which number is which color. You will have to go and look it up and it's such a small filed (varchar 10, maybe 15 max?) that there's really no performance impact. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2011 Share Posted July 28, 2011 How about ENUM('brown', 'black', 'blonde')? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.