Answer the question
In order to leave comments, you need to log in
How to properly design a table to store user test results?
Hello, tell me how to design the table correctly. How to save test results for users.
On the screen I described 3 options as it seems to me that this can be done, but it seems to me that I'm missing something or I just don't know how it can be done beautifully. I'm leaning more towards option 3.
Answer the question
In order to leave comments, you need to log in
Depends on the structure of the questions, as I understand it, you do not have a tree structure, but a list. The tables user_test_answers(user_id, test_id, question_id, option_id), user_test_result(user_id, test_id, status) are suitable for this.
The third Option, in fact, is the only adequate one. It's wrong to store JSON in a DB. Those. sometimes you have to, of course, when the task itself sounds like: "Make a database to store JSON." But in general this is not true. Well, what will you do, if necessary, filter users, depending on the answer? Parse JSON directly into SQL? Since you have chosen a database, then represent all entities by its means.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question