A
A
AlexRas2018-05-19 19:23:22
SQL
AlexRas, 2018-05-19 19:23:22

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.
5b004ed19b33f027977727.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2018-05-19
@AlexRas

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.

Y
Yuri Mikhailuts, 2018-05-19
@JBMurloc

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 question

Ask a Question

731 491 924 answers to any question