Quote:
The rub I'm getting hung up on is guaranteeing that ChecklistAnswers
associates a proper question-and-answer pair -- the relationship
|
that
exists in the version of the Template that its Checklist parent is
referencing. <
I am not sure if I understand correctly, but I notice that you seem to
have "ID" in each table as a primary key what might cause problems to
you as you do not use DRI properly then.
Does this help?
CREATE TABLE TemplateQuestionAnswers
(question_id INT NOT NULL
REFERENCES Questions(question_id),
answer_id INT NOT NULL
REFERENCES Answers(answer_id),
-- I would throw out the ID and create a proper primary key:
PRIMARY KEY (question_id, answer_id));
CREATE TABLE ChecklistAnswers
(checklist_id INT NOT NULL,
question_id INT NOT NULL,
answer_id INT NOT NULL,
FOREIGN KEY (question_id, answer_id)
REFERENCES TemplateQuestionAnswers(question_id, answer_id),
PRIMARY KEY (checklist_id, question_id, answer_id));
brgds
Philipp Post