I am having trouble thinking this (simple) table relation through. I am setting up a quick SQL DB to populate labels and textboxes dynamically on screens. This is just to prove we can do it, so it doesn't have to be the final set up. We will not be storing any response data at this time, so a storage table is not necessary. The requirements are:
1) One question can have many possible answer options.
ex: (True, False) (Yes, No)
2) One question can only have one group of answers.
ex: Group One: (True, False) Group 2: (Yes, No)
3) Many questions can use one group of answers.
ex: Drivers License? Group Two (Yes, No); Married? Group Two (Yes, No)
I'm drawing a blank on how to build a group of answers off of a set of answers, and allowing a question to only pull from that group of answers. Any help would be greatly appreciated 🙂
Thank you in advance.
Best Answer
Here's one idea:
That makes all of this legal:
But prevents this assigning, say, one question to more than one answer group:
Result:
A better design, as @DForck42 correctly observed:
Only slightly different sample inserts:
And of course since there is only one possible value to link a Question to an AnswerGroup, there is no need to demonstrate the prevention of multiple Question -> AnswerGroup associations.