Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,664 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,165 people online right now. Registration is fast and FREE... Join Now!




Question on how to handle store/handle survey answers

 
Reply to this topicStart new topic

Question on how to handle store/handle survey answers

iddimu
post 20 Sep, 2008 - 11:21 AM
Post #1


New D.I.C Head

*
Joined: 9 Sep, 2008
Posts: 3

Hi all -

I am trying to write some code to handle a survey. I need some advice on how to layout my tables/handle the survey answers.

I would have no problem with it if they were all multiple choice / yes-no type questions...my problem (and serious confusion) comes in when there is this:

CODE
10.  Can you say why you didn't use any medication?
     -  Didn't want to
     -  Didn't try
     -  Medical Reasons
     -  Pregnancy
     -  Financial Reasons
     -  Difficult to obtain
     -  Ins. doesn't cover
     -  Other _____________________


The possible selections in the above question are all checkboxes - so one to many can be selected. I could probably figure out how to handle that alright, but I'm getting thrown off by the "Other" selection.

Would I need to use a separate table for every question that has an "Other" option? That would seem kind of strange, but I'm no database expert by any means smile.gif

What about this:

tblSurvey
PK - SurveyID
FK - ClientID

tblQuestions
PK - QuestionID
FK - SurveyID
Question

tblAnswers
PK - AnswerID
FK - QuestionID
Answer

???

Does that make sense? If you need more clarification, please ask...

Thanks!

This post has been edited by iddimu: 20 Sep, 2008 - 11:22 AM
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 20 Sep, 2008 - 11:29 AM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Yup, that is exactly what you need to do. That model will also work for things like drop down boxes, radio buttons, and any controls which have more than one value.

Your responses (which I hope you are also storing in the database) will follow a similar pattern. However I am also experimenting with a way for responses to be stored as an XML format given the idea that your survey may eventually drop/edit/add questions as time goes on and I want people's responses to the survey to reflect the state of the survey at the time they answered.

But you are definitely on the right track with that thinking and you will find it very flexible. smile.gif
User is offlineProfile CardPM

Go to the top of the page

iddimu
post 29 Sep, 2008 - 09:35 PM
Post #3


New D.I.C Head

*
Joined: 9 Sep, 2008
Posts: 3

Thanks for your quick response, Martyr2!

Haven't had much time to work on this piece since I originally posted. I will update once I have a solution.

Your idea of storing the responses in XML is intriguing. The client didn't seem to think that their survey questions were going to change, and as such the pay I'm getting is representing that fact! So, I'm not overly concerned with the state of the survey at the time it was administered and don't want to over-engineer for what I'm getting paid...my main concern is how to keep the comments in the textbox associated to the 'Other' checkbox. I'll save the change in survey questions for another paycheck wink2.gif .

Thanks again!
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:47AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month