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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Designing database for Questionnaire responses

Author  Topic 

hasanali00
Posting Yak Master

207 Posts

Posted - 2004-10-18 : 05:15:25
Has anyone ever designed a database to store questionnaire response?

I am wondering what can be the easiest way to do so.

I can have a table which includes a userID, questionID and answer. But the problem lies in storing Multiple Answers to a question.

I have found one article at http://www.databasejournal.com/features/mssql/article.php/1441831

Any suggestions on storing and querying questionnaire results?

regards

Kristen
Test

22859 Posts

Posted - 2004-10-18 : 14:24:56
We use three tables to identify the questions, and one to identify the answers.

The question tables are:

Questionnaire Header (Questionnaire ID / Description of questionnaire)
Question Items (Question text, data type for answer)
Question Choices (for multiple-choice questions)

In the answer table we store UserID, QuestionnaireID, QuestionID, Answer

For multiple choice questions that allow multiple answers we store them as a comma delimited list.

Kristen
Go to Top of Page

hasanali00
Posting Yak Master

207 Posts

Posted - 2004-10-19 : 04:42:30
Thanks Kristen.

When u say:' we store them as a comma delimited list'
I believe u mean as: "answer1, answer2,..."

If I store the answers like this, how easy is it to query the result afterwards using SQL.

regards
Go to Top of Page

tuenty
Constraint Violating Yak Guru

278 Posts

Posted - 2004-10-19 : 12:33:40
it shouldn't be to difficult but you will have to use some inner joins or similar logics like exists or
implicit joins like from tableA, tableB Where tableA.fk =tableB.pk

*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*

A candle loses nothing by lighting another candle
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-10-19 : 14:13:56
"If I store the answers like this, how easy is it to query the result afterwards using SQL"

Well, it depends a bit what you want to use them for. In our case the questionnaires tend to be for ad-hoc thigs that the client wants to ask customers - i.e. they have no useful data within our systems that they can JOIN too.

"What do you think of our website?"
Fan***kingtastic
Very***kingtastic
Moderately***kingtastic
Brilliant
***kingAwfull

Actually, I'm not quite sure why that particular data-set would allow multiple selections, but Heh! that's presumably what the client said he wanted ...

There are a number of Splitter functions available on this forum; they allow you to have a parameter such as "a,b,c" and split that into multple rows of "a", "b" and "c" which can then be joined to otherthings.

But, if you are required to put the data in, say, Excel, then you aint got nothing to worry about!

SELECT QuestionID, Answer from MyQuestionnaire

gives: "1", "Cool,VeryCool"

Kristen
Go to Top of Page

hasanali00
Posting Yak Master

207 Posts

Posted - 2004-10-19 : 18:31:14
thanks
Go to Top of Page
   

- Advertisement -