The fact that your questions require just a yes or no answer doesn't make any
real difference; it simply means that there are only two possible answers
rather than four or five which might be the case with a multiple choice
question. Lets take one question as an example:
Have you stopped beating your wife?
The Questions table would have row for it such as:
QuestionID Question
--------------------------------------------------
42 Have you stopped beating your wife?
The Answers table would have three columns, the second being a text data
type, and for this question two rows such as:
AnswerID Answer QuestionID
----------------------------------
123 Yes 42
124 No 42
Using a text data type for Answer rather than a Boolean (Yes/No) data type
means that the table can hold answers to multiple choice questions as well as
simple Yes/No answers.
You'd have a table of Respondents, i.e. people answering the questions, so
if I'm dong so there'd be a row for me:
RespondentID FirstName LastName
----------------------------------------
666 Ken Sheridan
For the answers given to each question there would be a RespondentAnswers
table which models the relationship between the Respondents, Answers and
Questions tables and which includes a text or memo field for any
supplementary information. So if I answer Yes to the above question, but
qualify my answer with a comment there would be a row in the table:
RespondentID QuestionID AnswerID Notes
----------------------------------------------------------------
666 42 123 Starting again
soon.
You might also have a QuestionnaireID foreign key field in the last table
which references the primary key of a Questionnaires table which has columns
for the attributes relevant to the questionnaire as a whole such as its
title, date etc.
One important point about the above model is that the relationship between
the RespondentAnswers and Answers table should be on the two columns AnswerID
and QuestionID, and referential integrity should be enforced. This ensures
that the table can only accept rows where the AnswerID refers to a valid
answer to the question to which the QuestionID in the same table refers.
For data entry you would not have to enter the actual ID values into each
column in the RespondentAnswers table of course. On a form you'd have combo
boxes for RespondentID, QuestionID and AnswerID which list the text values
but are bound to the underlying columns of long integer number data type.
The user would then simply select a text value from each combo boxes list and
enter any comments into the Notes text box. This differs from the usual
layout of a paper questionnaire with check boxes of course, but that's simply
a reflection of the way that a relational database stores data in tables
which conform to the rigid 'rules' of the relational model, whereas the human
mind is able to cope efficiently with the expression of the same data in a
format which would be quite wrong and extremely inefficient in a relational
database.
So you can see how with a small number of tables having only a few columns
each you can handle any number of questions and answers whether these are
simply Yes/No answers or multiple choices. Moreover, in the case of the
latter, it will also handle multiple answers to one question of the type
'select one or more of the following with which you agree' type. By
correlating the QuestionID and AnswerID combo boxes the latter will only list
those answers which apply to the selected question; this is a little tricky
in a continuous form however as it need a 'hybrid' control made up of a text
box overlying a combo box so they look like a single combo box. I'd suggest
you concentrate on getting the logical model right before thinking about
these sort of refinements to the user interface however.
The ability of the database to handle both Yes/No and multiple answers to
questions doe have a small implication as far as data integrity is concerned,
because it would allow both Yes and No to be answered to the same Yes/No
question. In Access this can't really be controlled at the level of the
logical model, so reliance on enforcement in the user interface is necessary.
This reduction in application independence has to be accepted therefore. If
ALL the questions were of Yes/No type then it would simply require a unique
index on the RespondentID and QuestionID columns (and QuestionnaireID if
there is one) in the RespondentAnswers table.
Ken Sheridan
Stafford, England
Niniel said:
That was very helpful, thanks a lot.
My "questions", however, are a bit different in that they are all check
boxes, ie. yes/no questions, that sometimes require text input as well [the
"other" option]. In other words, questions 1 - 100 can only be answered as
yes or no, or yes and user-generated text in some cases.
How do I deal with that? I didn't quite understand your idea, and the MS
article you so kindly linked to suggested putting a "response" yes/no field
into a table with the questionID and the personID. But I'd still have to
store the text somewhere.