Jump to content

Best way to setup simple form submit / db


johnsmith153

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.