Solved

Database Structure & Code Assistance

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now