Save on database boolean expressions

I’m working on a web app about online questionnaires forms and i’m having a problem regarding saving on database question’s visibility.

In our forms the visibility of some questions is conditioned by the answers of other questions, for example you can see question “B” only if you answered question “A”.

For this simple case i have no problem to insert this information in the database, the problem is when i have visibility’s condition like this: D = (A AND B) OR C.

I found this post on stackoverflow with a similar problem but the final solution was not posted: storing and parsing boolean expressions in database

I can serialize the formula and save the string on the DB but i don’t like this solution cause i lose all the DB bond, i thought to save for each condition the next condition and specify the logical connective but this solution is not good for the parenthesis; the only good idea for now is to save the single condition on a table and the condition’s relation on an other table; any suggestion please?


Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.