0

https://postimg.cc/vDqtCNBc

We have different survey types. Each survey type has its own unique sections, and each section has its own unique questions. (Questions are not currently re-used by different survey types and may never be). For questions that are answered by tickboxes ('tick one only' or 'tick all that apply'), there are predefined answers, which are listed in the form_possible_answers table. The right side of the image shows the table relationships for this. Bridge table form_questions_answers_bridge determines which of the possible answers can belong to a particular question. (E.g. 'What condition is your car in?' will only be linked to the 'Excellent', 'Moderate', 'Poor' answers.)

When a form is submitted, details such as the form type and submission date are stored in the form_submissions table. This is where it gets complicated. There are 3 question types: a question that can have a single predefined answer (answered by ticking a single tickbox), a question that can have multiple predefined answers (answered by ticking all tickboxes that apply), and a question that is answered by user text input. I have a submitted_questions table that relates all submitted questions to the form submission. For text-answer questions (knowledge obtainable from the form_questions table), there is a text_answers table. For questions that are answered via a checkbox (single or multiple) there is a multiple_answers table that references the submitted question id and predefined answer.

The multiple_answers table references both the form_questions and form_possible_answers tables. One may question why I then have a bridge table form_questions_answers_bridge. It is a lookup--so I can enforce a constraint when writing data is attempted. (E.g. If the lookup/bridge says the answer 'no' is not possible for 'what color shirt?', then the data won't be written.) Is this a just argument?

philipxy
  • 14,867
  • 6
  • 39
  • 83
TWilliamson
  • 71
  • 1
  • 3
  • Does this answer your question? [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) – philipxy Aug 29 '22 at 07:41
  • [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/q/285551/3404097) [Why are images of text, code and mathematical expressions discouraged?](https://meta.stackexchange.com/q/320052/266284) PS An ERD is an image of DDL. PS Please insert images (when appropriate) via post editor functionality. [Help] PS "thoughts/suggestions" & "any advice" are not an on-topic question. [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/q/284236/3404097) [ask] – philipxy Aug 29 '22 at 07:43
  • What is your 1 specific researched non-duplicate question re how/why you are 1st stuck in what published presentation of what design method? – philipxy Aug 29 '22 at 07:43
  • It is an SQL idiom (for declarative constraint enforcement, because ASSERTION isn't implemented) that when we have is_of_subytpe(x, subtype) & we want to add foo_of_same_subtype(x,y) we add instead foo_of_same_subtype(x,y,subtype). This is a faq. But one must write many clear, concise & precise phrasings of one's question/problem/goal to search reasonably. – philipxy Aug 29 '22 at 09:37

0 Answers0