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
https://forums.phpfreaks.com/topic/243118-best-way-to-setup-simple-form-submit-db/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.