1

My app has this menu:

  1. TestMode - make a quiz with 26 rndom questions from the database with a timer of 30 minutes.
  2. LearningMode - make a quiz with all the questions from my db, displaying the correct answers.
  3. 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:

enter image description here

I don't know if is better if I put answers in questions; and if I do that, how to store the correct answer.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Jun 10, 2018 at 0:16
2
  • 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? Commented Jun 10, 2018 at 0:47
  • yes i need it after restart... Commented Jun 10, 2018 at 7:10

1 Answer 1

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.

answered Jun 10, 2018 at 16:33
2
  • is it really? the question states that multiple choices can be correct Commented 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. Commented Jul 29, 2021 at 10:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.