Solved

Database Structure & Code Assistance

Posted on 2012-03-21
3
231 Views
Last Modified: 2012-06-27
Greeting Friends,

I trying to develop a survey app and in need of assistance.  

For each question the survey author can choose from three answer types, rating, yes/no and text. If they choose rating as the question type they are required to enter the rating choices separated by a comma (question1options).

The issue is with joining the questions that have a type set as rating.

So here the db current structure.
- Survey Table -  
surveyId
question1
question1Type
question1options
question2
question2Type
question2options
ect...

- Answers Table -
answerId
surveyId = 1
answer1

What the data looks like

- Survey Table -
surveyId    = 1
question1 =    How would you rate the service?  
Question1Type =  rating
question1Options =   Terrible, Okay, Neutral, Average, Excellent


- Answers Table -
answerid      surveyid      answer1
1                    1                Average
2                    1                Okay
3                    1                Average  


What I'm trying to accomplish with the results:

1. How would you rate the service
    Terrible - 0
    Okay - 1
    Neutral - 0
    Average - 2
    Excellent - 0
 
Thank you in advance for reviewing my question.
0
Comment
Question by:GrantBailey
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 37749035
eek!!

This has to be a matter of personal design, but ...

I'd try starting with a Questions table like this:
QuestionID  (just an int)
QuestionType  (1, 2, or 3 for your three types)
QuestionText
Other info so you can display the question

And a SurveyQuestions table (that defines which questions go in a survey, and their basic sequence

SurveyID
SequenceNr  (an int, just 1, 2, 3, 4)
QuestionID  (which question from Questions)


And a Reactions table, which defines, for each question, what question to go to next for each reaction (when the user has a ratings question). You use this to define destinations for each of a set of possible answers defined by radio buttons (so you can go one place if the user gets it right and somewhere else if he gets it wrong!)

SurveyID
QuestionID
ResultValue       (what was selected)
SequenceNr    (where to go to because of this selection)

That's how I'd start out building it, and then add on things needed for displaying the questions and storing the answers  ...
0
 

Author Closing Comment

by:GrantBailey
ID: 37749514
Your right the structure is completely wrong. Thanks for the assistance.
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 37750102
Happy to help out!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question