Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2007-02-10 : 05:06:20
|
| HiI need to create a web based survey, and would like to have the questions and the answers saved in a database. Have anyone done this before, any tip on how to build the database for this purpose is greatly appreciated.Regards |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2007-02-10 : 05:13:38
|
| This question is very broad. The DB tables can vary drastically depending on the needs of your survey. The simplest answer for a db is two tablestbl_User(UserID,Name,Address,Address2,Email,etc)tbl_Questions(QuestID,Question)tbl_Answers (AnsID,QuestID,UserID,Answer)But in all likley hood you will have other factors you will need to factor in, but that's the basic idea of what you want to accomplish. |
 |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2007-02-10 : 05:28:24
|
| HiWell this would work fine for questions that have one answer I guess, but my survey will also have questions with different answers to select from (radiobutton group). What do I need to change to also support this?Regards |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-02-11 : 05:27:02
|
| We have database tables for this that have the questions in the database too - this allows the Site Owner to set up new surveys.So we have tables like:Survey - SurveyID, title of survey, start/end date, etc.Survey items - SurveyID, SurveyItem, Question, Answer datatype (Yes/No, MultipleChoice [see Survey Choice table], Number, Free text)Survey Choice - SurveyID, SurveyItem, Choice, AnswerAnd then:User - UserID, Name, other contact detailsAnswers : userID, SurveyID, SurveyItem, AnswerWe have multiple columns for the "Answer" - one each for Text, Number and Boolean. We store the answer in the appropriate one according to the question's DataType. We store a "number" if the question is a Multiple Choice.Other columns to consider:Survey - IsActive, Reward URL (URL to visit when survey completed), Confirmation EMail details (From, Subject, Body)Survey items - For numeric DataType items Min & Max values, Additional datatypes - e.g. DateTime Could also consider Language - so that Questions and Choices could be language-specific. (Would need to also record Language Code in the User's record)Kristen |
 |
|
|
|
|
|
|
|