My question is in regards to normalizing data.
INFO
I’m trying to tabulate test results in a database. The information I’d like to record is test_instance, user_id, test_id, completed(date/time), duration (of test), score, incorrect questions and reviewed questions.
For the most part, I think I’d organise the info according to TABLE 1, but I’ve come a little unstuck trying to work out the best way to record incorrect or reviewed questions. Please note that I DON’T want to put all the incorrect questions together in one entry as per TABLE 2.
I’d like to make a separate entry for each incorrectly marked question (or reviewed question).
NOTE: Reviewed questions are ones that at one time or another were marked incorrectly and hence need to be tested again.
TABLE 1
-------------------------------------------------------------
| instance | user_id | test_id |completed |duration|score|
-------------------------------------------------------------
| 1 | 23 | 33 | 2JAN2012 | 20m | 75 |
| 2 | 11 | 12 | 10DEC2011| 35m | 100 |
| 3 | 1 | 3 | 3JUL2008 | 1m | 0 |
| 4 | 165 | 213 | 4SEP2010 | 10m | 50 |
-------------------------------------------------------------
TABLE 2
------------------------
| instance ||wrong Q|
------------------------
| 1 || 3,5,7 |
------------------------
Ultimately, I’d like to know how many times a user has gotten a particular question wrong over time. Also, I need to keep track of which test the wrong questions came from. This is the same for the reviewed questions.
Incidentally it’s possible for questions to be reviewed AND wrong in the same instance.
I’ve come up with 2 different ways to represent the data, but I don’t like either of them.
-------------------------------------------------
| instance | Q number | Wrong | Reviewed |
-------------------------------------------------
OR
---------------------------------------------------
| user_id | test_id | Q number | Wrong | Reviewed |
---------------------------------------------------
Note: Wrong/Reviewed category is counting how many times the Q number falls into that category.
MY QUESTIONS SUMMARISED
How can I efficiently represent wrong/reviewed questions in a table? Is TABLE 1 set up efficiently?
EDIT : Questions that have been answered incorrectly can be used to generate new tests. Only incorrect questions will be used for the tests. If a generated test is taken, the questions tested will be marked as reviewed. The score will not be updated as it will be a new test and a new test_id will be generated.
NOTE-It is possible to retake old tests, but the score will not be updated. A new instance will be created for each test that is taken.
In regards to the generated tests, I guess this means I will need to include one more table to keep track of which quiz the questions originally came from. Sorry- I hadn’t thought it all the way through to the end.
THANKS
It was difficult for me to choose an answer as everyone gave me really useful information. My final design will take into consideration everything you have said. Thanks again.
Talking about normalization, and just to make sure that you can retrieve all kind of calculated data out of your database, I’d propose a more complex model, which will end up in something easier to manage…
You’ll need the following tables
Back to your needs, we then have the following: