View Full Version : Which sql datatype to use for drop downs and checkboxes
ProfessorDan
08-23-2008, 11:32 PM
I'm not sure if this has already been asked elsewhere, but I just have a couple questions about which datatypes to use for certain form fields. I can't find the answer anywhere, but I just need to know which data type to use for a drop down menu, and which one to use for a checkbox.
I'm building a questionnaire for my dad's website, and one field is a proficiency/experience rating (1-5 in a dropdown menu), and the other is a checkbox for them to determine their availability for certain tasks.
Those are the only two I need to know, I'm fine with the rest of it.
Thanks for any help. :)
felgall
08-24-2008, 01:08 AM
tinyint can hold up to 256 different values which is more than enough for those fields.
ProfessorDan
08-24-2008, 03:37 AM
Ok, thanks for your help. :)
dataman
08-24-2008, 04:41 AM
It depends on the type of data you want to store in your table(s). As Fengall mentioned, if your intent is to store vary small value integers, then tinyint is the solution. If on the other hand you want to store a fixed value (pre-specified in the table) then enum might be a solution (like "Y" or "N"). Single character text would be reflected as a char type. Multiple character text like "black" "red" etc. would be specified as a varchar type.
Suggest you check the MySQL manual for additional information.
DataMan
ProfessorDan
08-24-2008, 09:36 PM
Well here's an example of a question. "How proficient are you are you at writing?"
and then there would be a drop down menu with numbers 1 through 5 for them to choose from. So the data that is received will be a number from 1 to 5. The only reason I question it is because it's coming from a drop down menu instead of just being typed in a text field. Does that make a difference or not? If not, I think tinyint would be fine.
:)
felgall
08-25-2008, 12:33 AM
How the data is entered doesn't matter, it is what you are storing in the database that determines the type you need there.
ProfessorDan
08-25-2008, 03:11 AM
Well that's all I need to know then. Thanks for telling me that. It helps me a lot. :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.