473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Summary of Results

I've designed a database to hold responses to Surveys. What I want is to allow users to look at the results in a non graphical way, so 15% said Yes 75% said no, etc. I know that I can create queries that count and group by, so those figures are possible, but this means that I have to create a seperate query for each question, and with over 100 questions this gets slightly ridiculous. Secondly, I'm going to hopefully extend the database to encompass all the surveys that have been undertaken to make them easily accessible, so you can see why this would be annoying! Is my only other option to link to a PDF with this information already processed?

Thanks!
Aug 17 '09 #1
17 1732
ChipR
1,287 Expert 1GB
Depending on the structure of the data, you should not have to create a seperate query for each question. What tables do you have?
Aug 17 '09 #2
ajalwaysus
266 Expert 100+
you should be able to group by each question on the survey, that way your query will have all questions asked, and all responses as well all in one query.

i.e..
Expand|Select|Wrap|Line Numbers
  1. SELECT QUESTION, ANSWER, COUNT(ANSWER) AS COUNTOFANSWER
  2. FROM TABLE_SURVEY
  3. GROUP BY QUESTION, ANSWER
  4.  
You will still need 2 queries, the above query would give you your count by answer (Yes, No), you will then need a query to get you a count of all by question.

i.e..
Expand|Select|Wrap|Line Numbers
  1. SELECT QUESTION, COUNT(ANSWER) AS COUNTOFANSWER
  2. FROM TABLE_SURVEY
  3. GROUP BY QUESTION
  4.  
Then you can join both queries to give yourself all the percentages you need.

Let me know if this makes sense,
-AJ
Aug 17 '09 #3
It's a table called "Questions" which contains alll the questions with their answers already predefined. Each field is a seperate question. I'm a little perplexed by your answer ajalwaysus, as when you enter your response into a query it then asks to which QUESTION am I referring (i.e. Parameter Value). Am I just being idiotic?
Aug 17 '09 #4
ajalwaysus
266 Expert 100+
Please post a table structure, this may help us understand how we need to approach this, my query was meant to be generic, and you would need to tweak it as needed.

-AJ
Aug 17 '09 #5
Here's a picture of the structure. I'm sorry if it's stupidly small the upload would only allow, well, stupidly small.
Attached Images
 
Aug 17 '09 #6
This looks better. to me anyway
Attached Images
File Type: jpg Structure2.jpg (12.9 KB, 154 views)
Aug 17 '09 #7
ajalwaysus
266 Expert 100+
OK, this is a lot different than I thought, I don't even know if a query is possible on the table you have now. As a piece of advice, I would rather you do this right, so if you have the time, I think you need to approach this differently. When I designed a survey database, I had at least 4 tables (Questions Table, Answers Table, QuestionXAnswer Table, Results Table).

The Questions table housed all possible questions with this structure:
Question_ID (Auto Number)
Question

The Answers table housed all possible answers with the structure:
Answer_ID (Auto Number)
Answer

The QuestionXAnswer table housed all the cross references of Question and Answer (it gave you the question with each possible answer) with the structure:
Question_ID
Answer_ID

The Results table housed all answers with the structure:
Question
Answer

Now I think this can be made a lot better, survey databases are something I have never been a fan of. I welcome any tweaks or overhauls. =)
Aug 17 '09 #8
ChipR
1,287 Expert 1GB
For the most flexibility, I'm thinking something like:

tblQuestions
QuestionID
Question
CorrectAnswer

tblSurvey
SurveyID
Description/Title/Notes

tblSurveyQuestions
SurveyID
QuestionNumber
QuestionID

tblSurveyTaker
TakerID
TakerName
Gender
Age
etc.

tblSurveyTaken
SessionID
SurveyID
TakerID
SurveyDate
Location

tblAnswersGiven
SessionID
QuestionNumber
AnswerGiven
Aug 17 '09 #9
I've seen this kind of structure of late (annoyingly after I'd written the database) in a few forums. What I can't quite get my head around is how the answers are stored. So I have a table that contains the question and the possible answers, so a row for each possible answer with repeated question. Then a table of the survey ID and what it is. These then relate into which questions relate to which survey (manual input I'm assuming). I have a table that represents who's responding with their personal data, that then relates into a table of when they took which survey, a session ID. But then, this session ID then relates to a seperate answer given field in another table with just the question number. If I've already had to enter all the responses into the first table, tblQuestions, why then am I entering in the response again. And also does this then mean that for every question response I get there is another field in tbl AnswersGiven?

Sorry just trying to wrap my head around it all!
Aug 18 '09 #10
ChipR
1,287 Expert 1GB
For multiple choice, my tblQuestions would have to have the choices added. Maybe:

tblQuestions
QuestionID
Question
ChoiceA
ChoiceB
ChoiceC
ChoiceD
CorrectAnswer

Notice there is no field for a response. The question is its own entity.

Yes, in my design, every response is a record in tblAnswersGiven.
Aug 18 '09 #11
Hi,

So, if there are questions with different numbers of choices then it would just be case of leaving those fields blank yes? I'm not sure I understand what the CorrectAnswer field is for, being a survey there is no correct answer.

Sorry, feel like im probably being dense!

Alex
Aug 18 '09 #12
ChipR
1,287 Expert 1GB
As you can see, I'm no expert on surveys. You don't need a CorrectAnswer field if there isn't one. I think would arrange the choices in records that way, but if you want a more variable number of choices, you could make another table of

tblChoices
QuestionID
Choice
Aug 18 '09 #13
So, I think I'm nearly there, the last thing I think I need help with is the answer given field in tblAnswersGiven, I understand how to get it available so that they can enter a response but how do I limit it to the choices available? I can't use the validation text property or the input mask obviously, does this mean that for each individual input box on a form I would have to format them?
Aug 18 '09 #14
ChipR
1,287 Expert 1GB
Seems like a combo box would work. The source would just be
"SELECT Choice FROM tblChoices WHERE QuestionID = " & QuestionID
or the list of values of ChoiceA, ChoiceB, ChoiceC, ChoiceD. Depending on how you structured it.
Aug 18 '09 #15
NeoPa
32,556 Expert Mod 16PB
I don't want to take anyone off track here (all going well it seems) but I suspect (from your original design) that you might benefit greatly from going through Normalisation and Table structures, provided by one of our most prolific contributors.
Aug 18 '09 #16
I do understand normalization, I promise!

Got a slight other problem, all relationships set up and works in that sense. Just producing forms and I can create a form that allows me to create questions and assign choices per question, however I need a form that will relate those questions to the specific survey. What I was thinking of is a form with a subform, so the main form is selecting which survey and then the subform contains records of the question and question number, but this means to relate them I need to have the SurveyID in the subform (obviously) but of course the form is trying to generate new records where I actually need it to just look up whats already been input in a way that a layman would understand. Is it sensible to just use the table tblSurveyQuestions and turn it directly into a form and then mask the SurveyID and the QuestionID? This would be annoying however as for every new assignment you'd have to select the Survey again!

Thoughts?
Aug 19 '09 #17
Oh thought it might be helpful to post my relationships
Attached Images
File Type: jpg Relationships.jpg (16.1 KB, 184 views)
Aug 19 '09 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.