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
 Old Forums
 CLOSED - General SQL Server
 how to handle tons of questions...

Author  Topic 

jhermiz

3564 Posts

Posted - 2004-05-03 : 13:47:32
Im creating a small wizard to allow our business guys to answer some questions. The answering of these questions will help the end user choose the correct template for the station that he / she is trying to build.

Questions can be like so:
Is section monitoring required [IF YES THEN CHOOSE COMPONENT T720]
Are dual palm buttons required [IF YES THEN CHOOSE E0416]
Is a pneumatic plate required [IF YES CHOOSE T100]

....

There are abot 40 different questions....all of which can be yes's and no's...the yes's will allow the component to be added to basically their BOM. How should I handle these questions on the database side? I need to first store the questions themselves..and prolly feed them to my front end since they may change. But how should I store the answers etc...

I want to do it the right way and right now all I can think of is to actually store the question and a bit to flag it as yes / no???

Thanks,
Jon

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-05-03 : 14:35:52
The way I've done this sort of thing is have a table for Questions, and another table for their related possible answers (one row per answer per question).

I then create other tables that store a user's answer's to a particular set of questions.

Does that help? Let me know if I need to be more specific.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

jhermiz

3564 Posts

Posted - 2004-05-03 : 16:56:08
Can you be more specific...

I understand the table of questions not a problem.

But the only choices the end user may potenitally (bad bad spelling) have is Yes / No...there are a few that actually ask for a quantity...but how are you storing the rest? Do you relate a questionID to an Answer???

Thanks,
Jon
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-05-03 : 17:43:31
Ok, I've got a Question and Answer tables. A Question can have Many Answers. You can have different QuestionTypes or AnswerTypes to handle how to prompt the user (a Textbox vs radio buttons). This does sorta suck for a yes/ No type answer, but if you do it this way, You can easily see what questions a user has answered, and which one's they've yet to answer.

I then have a Users table. When a user answers a question, I have a Many-to-Many table that contains a UserID, an AnswerID (from the answer table), and an AnswerValue column. Think of this as "an instance of an Answer". Depending on the type of question, I'll put diffferent stuff in that value colum (1/0 for yes no, or a string of text for a textbox).

For my application, I also made groups of questions into a survey. Each user was allowed access to one or many surveys. When they logged in, I determined what they could see. Once they choose a survey, I knew what questions and what answers to those questions I needed to display.

HTH!

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -