tbl_Tests: remove "NumberOfQuestions". This will be calculated at query time by counting the number of questions assigned to the test through the other tables. Otherwise you'll need to employ triggers on those other tables to keep this number up to date
as questions are added/deleted (and don't assume they won't be).
I would remove the "correct" column from tbl_Answers, and instead move the "Score" column out of tbl_UserAnswers and into tbl_Answers. The score will be zero for incorrect answers and whatever value you place on the question for the correct answer.
You might want to include LocalLangID in tbl_Answers, even though you can get it from tbl_Questions, there might be some instances where you can eliminate a JOIN just to get it.
I would put an identity column in tbl_TestUserAttempts and use that as a FK in tbl_UserAnswers instead of the Attempt column. Otherwise how do you know which test an answer applies to? It could be the same question in the same attempt on 2 different
tests.
Thanks for your replay.
I agree with you in most of your points. However, NumberOfQuestions will store how many questions will be displayed for a test. For example, we can have test "a" and NumberOfQuestions of lets say "40". This is not the number of questions we are going to
store for each test, we can have as many as we want but will randomly pull only 40 to display.
To make ecen clearer, we will have x number of sections for each test - typically 4. each section consists of 10 questions that will be pulled out randomly, that's why I have TestSectionID in tbl_Questions as a question has to belong to a section for a test.
ziad08
Member
2 Points
2 Posts
Re: Database design for online test
Dec 21, 2011 02:16 PM|LINK
Thanks for your replay.
I agree with you in most of your points. However, NumberOfQuestions will store how many questions will be displayed for a test. For example, we can have test "a" and NumberOfQuestions of lets say "40". This is not the number of questions we are going to store for each test, we can have as many as we want but will randomly pull only 40 to display.
To make ecen clearer, we will have x number of sections for each test - typically 4. each section consists of 10 questions that will be pulled out randomly, that's why I have TestSectionID in tbl_Questions as a question has to belong to a section for a test.
Thanks