Solved

Database Structure & Code Assistance

Posted on 2012-03-21
3
232 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

840 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