Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database Structure & Code Assistance

Posted on 2012-03-21
3
Medium Priority
?
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

670 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