Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How do I represent this data?! Reply To: How do I represent this data?!

#151545
FahimDaDream
Participant

For the database layout I did have a similar layout. But yes, the difficulty will come from the fact that depending on the answer to Question A and Question B is where I choose my next SET of questions.

I was thinking I store the questions, their options, and the set they belong to in a database. Then I use either JSON or some other data type to quickly reference which is the next set of questions I should pull?

So I’d have something like.

A table to store questions (like you have)
A table to store options (like you have)
A table to map questions to which set they belong to.

And Some sort of data type to say
if SetID = 1 and the order of answers are, “ringo, blue, yes, no” go to set 2
if SetID = 1 and the order of answers are, “John, green, no, no” go to set 3
if SetID = 1 defaults go to set 5

But this would be really rigid because it would require knowing the possible answers before hand as well as the number of questions in the set. But I can think of no other way of doing it.