Here's a scenario:
I've made an online quiz for students to take. The answers to the questions can be a mix of true/false, whole number addition, division, or essay questions. What would be the best way to design this db so I can get all of the results in one query (using MYSQL)?
My thoughts:
You would want to split it up by data type so you don't have a bunch of null rows - that way can you do joins easily
Design the db something like this maybe:
`true_false`
--------------------------------
question_id | int
answer | tiny_int
`addition`
--------------------------------
question_id | int
answer | int
`division`
--------------------------------
question_id | int
answer | double
`essays`
--------------------------------
question_id | int
answer | text
`question_text` (actually stores the questions)
--------------------------------
question_id | int
question_text | text
...although I suppose you could probably store all the numeric answers in one table as a double (or floating point number), but how would I get all of the data into one query so I get one question id and one answer per row retrieved?
Your thoughts are appreciated
Steve