Jump to content

Survey app


lugos

Recommended Posts

Hello,I would like to create a very small and simple PHP app to conduct an anonymous survey. The survey would be about 10 questions max, and there would be 4 or 5 possible answers for each. I would also like to store the results in a table. What would be the best way to set up the table? Should I have a row for each question and then 4 or 5 integer columns that are only updated if the user has selected that specific answer to that question? For instance if the user answers option 2 for question number one, then I would update row one, option_2_column_name. Any thoughts/ideas?Thanks in advance.lugos

Link to comment
Share on other sites

The answer depends on the degree of flexibillity and control you require.The easiest solution is probably to have a wide table of bit/boolean checks enumerating each answer option:AnswerTable: RespondantId, Q1A1, Q1A2, Q1A3, Q2A1, Q2A2, Q2A3, Q3...This allows you to handle questions that allow multiple answers. Simply having one int/varchar column to record the index or text of the answer is fine as long as you don't have any multiple choice options.Write-in / other answers can be recorded in the same structure in line as: Q[n]Other.One advantage of this technique is that the bit columns take up very little space allowing you to make a very wide table if need be. Reporting queries will be wordy by easy to write.However, this solution breaks the rules of relational data... if you care about that sort of thing.........The relational answer might look something more like this:SurveyQuestionsTable: Qid, Qtext, Qsort, Qtype (single,multiple,single+other,multiple+other) Qtype specifies wether multiple responses are allowed and may give hints to the app as to which control to use (checks / radios)

Link to comment
Share on other sites

sorry, I'm apparently having trouble with posting duplicates, I swear I'm not hitting the button 5 times. sorry.

Link to comment
Share on other sites

sorry, I'm apparently having trouble with posting duplicates, I swear I'm not hitting the button 5 times. sorry.

Link to comment
Share on other sites

sorry, I'm apparently having trouble with posting duplicates, I swear I'm not hitting the button 5 times. sorry.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...