Pierre56
Pierre56

Reputation: 567

SQL - User Stats table?

I am working on a multi-choice questions web-app. A user will have to answer 50 to 100 multiple-choice questions. The number of possible answers for each question can differ from 3 to 4 but there is only 1 correct answer.

I would like to create a page stats where the user can come back to the answered questions and see what answer he did select. I am not sure what would be the proper way to do that.

So far I have:

users table

enter image description here

questions table enter image description here

answers table enter image description here

Upvotes: 0

Views: 94

Answers (1)

derstauner
derstauner

Reputation: 1796

I would organize the answers table like this:

enter image description here

In that way:

  • you will not have columns with null values,
  • you can have questions with more than 3-4 answers too without adding any extra column
  • you can have questions with multiple right answers too

Then, you will need a table, which holds the user's answers:

enter image description here

Now, you can easily construct a query, which shows the required data.

Upvotes: 1

Related Questions