Search code examples
databasedesign-patternsdatabase-design

Dynamic Survey DB Model - Display Questions based on Logic


I am building a survey application that allows users to create and distribute surveys.

I have the survey DB model almost complete, with the exception of handling 1 part.

I want users to be able to add logic to the survey.

Below is my current DB model, how can I modify this to handle custom logic. Is this even possible?

By logic I mean to show/hide question based on the answer to other questions.

I.e. If (Question 1 == true), then (show Question) 2 else (show Question 3).

enter image description here


Solution

  • I think you can extrapolate you survey logic as directed graph. So each state will be represent the replay stage and transition will be represent logic of survey based on previous replies.