T
Tim Cali
Hi. I am revising a survey database and I would like to know if I should
create a formal relationship between 2 items in it.
The first table is simple:
tblQuestions
QuestionID
Question
In the database, certain questions are open-ended and others are
pick-from-list only. So for example a pick-from-list question "do you like
to surf?" might have responses:
- yes
- no
while another pick-from-list question would have other choices. I am
wondering how to represent this in the database. Duane Hookum's
AtYourSurvey.mdb allows QuestionID to be assigned at the response level,
something along the lines:
tblResponses
RspnsID
QstnID
with QstnID a foreign key to QuestionID of tblQuestions. I like this because
there is a solid relationship between the tables. However, in my survey
there are several questions that have yes/no choices, so I would have to
replicate as many yes/no responses for as many questions that allow them,
negating my ability to "re-use" the pick-from-list.
So, my question is, will setting up an unattached table violate the
commonly-accepted rules of database design? Or, is this an acceptable
workaround for my situation? Here is what I mean.
I could design it this like:
tblQuestions
QuestionID
Question
ItemRef
tblResponses
ResponseID
Response
ItemRef
e.g.
tblQuestions
QuestionID Question ItemRef
1 do you eat broccoli? 2
2 do you like to surf? 2
3 what is you fav color? 3
tblResponses
ResponseID Response ItemRef
1 Yes 2
2 No 2
3 Red 3
4 Blue 3
5 Black 3
6 Green 3
'etc
This allows me to reuse the lists as many times as I want. But the problem
is that the relationship is implied, not forced.
The ultimate solution that I can think of would be to set up a many-to-many
relationship between tblQuestions and tblResponses, which would allow me to
reuse the items in the responses. However, I would have to create some much
more comples forms to handle this and I am trying to find an appropriate
trade-off between amount of work to be done and the payoff of the fruits of
my labor.
To restate the question, do any of you set up database with some tables
"detached" and, therefore, a relationship implied, or is it preferred to
always set up proper relationships and avoid a "quick fix" such as this?
What would any of you do in this case?
create a formal relationship between 2 items in it.
The first table is simple:
tblQuestions
QuestionID
Question
In the database, certain questions are open-ended and others are
pick-from-list only. So for example a pick-from-list question "do you like
to surf?" might have responses:
- yes
- no
while another pick-from-list question would have other choices. I am
wondering how to represent this in the database. Duane Hookum's
AtYourSurvey.mdb allows QuestionID to be assigned at the response level,
something along the lines:
tblResponses
RspnsID
QstnID
with QstnID a foreign key to QuestionID of tblQuestions. I like this because
there is a solid relationship between the tables. However, in my survey
there are several questions that have yes/no choices, so I would have to
replicate as many yes/no responses for as many questions that allow them,
negating my ability to "re-use" the pick-from-list.
So, my question is, will setting up an unattached table violate the
commonly-accepted rules of database design? Or, is this an acceptable
workaround for my situation? Here is what I mean.
I could design it this like:
tblQuestions
QuestionID
Question
ItemRef
tblResponses
ResponseID
Response
ItemRef
e.g.
tblQuestions
QuestionID Question ItemRef
1 do you eat broccoli? 2
2 do you like to surf? 2
3 what is you fav color? 3
tblResponses
ResponseID Response ItemRef
1 Yes 2
2 No 2
3 Red 3
4 Blue 3
5 Black 3
6 Green 3
'etc
This allows me to reuse the lists as many times as I want. But the problem
is that the relationship is implied, not forced.
The ultimate solution that I can think of would be to set up a many-to-many
relationship between tblQuestions and tblResponses, which would allow me to
reuse the items in the responses. However, I would have to create some much
more comples forms to handle this and I am trying to find an appropriate
trade-off between amount of work to be done and the payoff of the fruits of
my labor.
To restate the question, do any of you set up database with some tables
"detached" and, therefore, a relationship implied, or is it preferred to
always set up proper relationships and avoid a "quick fix" such as this?
What would any of you do in this case?