I want to create an open ended questionnaire feature on my Website. Admins manage their own site and they can create open ended questions (like a survey) that include things like menus, radio buttons, input, textareas and checkboxes. (Standard stuff).
I've written the admin side so that these are created on the fly based on the admin set up. So different sites can have different quantities of answers. I'm now looking at the best ways of storing the user answers.
So for each user, I need to record:
1) Their user ID
2) The questionnaire ID (which questionnaire they are on)
3) The answers to the questions (varying number of questions).
I see two ways of doing this:
1) A set up where each user has ONE record with three fields.
- user response
The user response field is a text field that contains a serialized string with their answers.
2) The second way is to set up a database where the schema is that there will be as many records for each user as there are questions. So now we add a fourth field.
- questionnaire ID
- question ID
- single answer response
The advantage I see to the first method is a more compact database (i.e. less records).
The advantage to the second is that you can pull individual data for a particular question without having to un-serialized the whole record.
My question is this. Is the efficiency gained by the first option any consideration? Or does it make more sense to just use the second option even though it greatly increases the number of records in the database (e.g. If you have a questionnaire with 12 questions and 100 people answer it, option one means 100 records but option two goes right to 1200).
Any insight offered would be helpful. Thanks.