sql - How to maintain referential integrity with common great-parent table? -
Let's say I have a table with "group of questions"
GroupID | Price -------- + ------ 42 | How often do you work 9071 | Other questions ...
And, for each group's questions I have "question" and "possible answer"
group | Question ID | Price ------ + ------------ + ------ 42 | 5 | ... brush your teeth? 42 | 89 | ... go to the movies? 9071 | 70 9 ... another question ... ...
group | Answer: Price ------ + -------- + ------ 42 | 134 | Many times per day 42 | 135 | Twice a day 42 71 | Once a day 42 803 | Every other day 42 8 | Once a week 42. 666 | Once in a month ...
Now, in PHP / HTML, I do a complete cross product of one (virtual) questions and to make 42-answer possible replies to a 2-entry table where the user They will select / answer ()
how often do you do. N / D | 2 / D 1 / D D * 2 | 1 / w | 1 / m | ---------------------- + ----- + ----- +----- + ----- + --- - + ----- + ... brush your teeth? | () | (X) | () | () | () | () | ... go to the movies? | () | () | () | () | (X) | () |
I know that I want answers (questions, answers, ...) values (5, 135, ...) to insert The question is: (e.g., question, answer, ...) values (70, 71, ...) for teeth
< answer
related to the group of questions in the table "related "What is the method of applying both the question and answer?
Disapproved, because question 709 "Group" belongs to 9071 and North 71 belongs to Group 42.
You type column group
, questionID
and answer
Then two foreign keys, one (group, question id)
and (group, answer)
on the other.
Comments
Post a Comment