My app has this menu:
- TestMode - make a quiz with 26 rndom questions from the database with a timer of 30 minutes.
- LearningMode - make a quiz with all the questions from my db, displaying the correct answers.
- Statistics- display % of quiz passed and the questions with wrong answers (displaying the correct answers).
- each question have 3 choices(1 choice can be true, 2 choices can be true, or all can be true).
- question can have a picture or not.
For now my db structure looks like this:
I don't know if is better if I put answers in questions; and if I do that, how to store the correct answer.
-
Is your requirement to store the wrong answers in the db or just in memory? In other words, do you need to store the results so they are available when the application restarts?CodingYoshi– CodingYoshi2018年06月10日 00:47:35 +00:00Commented Jun 10, 2018 at 0:47
-
yes i need it after restart...cikicean– cikicean2018年06月10日 07:10:39 +00:00Commented Jun 10, 2018 at 7:10
1 Answer 1
The correct answer is the property of the question.
Thus, the question table should be improved by a column named correct_answer_id
, which will be a foreign key to answer(id_answer)
.
We can see some similar in the database of the Stack Exchange - here the accepted answers are in the AcceptedAnswerId
column.
This structure has a possibility of inconsistence - nothing guarantees that the correct_answer_id
refers to an answer which belongs to the current question. Ideally, you should use contraints to ensure that.
-
is it really? the question states that multiple choices can be correctTom V– Tom V2021年07月29日 08:54:13 +00:00Commented Jul 29, 2021 at 8:54
-
@TomV Right, I think the answers need a boolean property showing if they are correct. I fix it soon.peterh– peterh2021年07月29日 10:25:31 +00:00Commented Jul 29, 2021 at 10:25