Forum Moderators: coopster
I need some advice on designing a database for an online questionnaire i am creating. Basically i was thinking of either:
Having the fields:
userID ¦ Question1 ¦ Question2 ¦ Question3 etc
and have a row for each person who fills out the questionnaire
or:
userID ¦ Question number ¦ Answer
and having a row for each answer that each person gives
What do you think would be the best approach for this in terms of performance.
Cheers
Richard
QUESTIONS
question_id
question
ANSWERS
answer_id
question_id
user_id
answer
USERS
user_id
username...
Horizonal is certainly much, much faster, but if you're not 100% certain you won't be changing the questionnaire often, it's best to go vertical. What I do in these cases normally is try and go horizontal with "room to grow" -- add a few extra columns up front that I can use later and write extraction code to use them if they exist and ignore them if they don't. That way I don't have to go back and re-write code over and over.
S