QID------QDESC-----CHID----SID
____________________________
1 ---------abc---------NWL-----PHY
2 ---------def---------CGM------MTH
3 ---------sdf ---------CGM-----MTH
4 ---------jkl ---------OPT------PHY
5 ---------tyu ---------THC------CHM
6 ---------fgd---------CGM------MTH
7 ---------fwr----------NWL------PHY
8 ----------ghi----------THC------CHM
.
.
_____________________________
PHY - Physics, CHM - Chemistry, MTH - Math
love your job and not your company;
...because you never know when your company will stop loving you!
shukla raghav wrote:1. I am creating an online examination system. Here several users will be able to give the test simultaneously.Because it is a time sensitive application i am generating the entire Test specific to every student and putting it in the Session context. rest all the requests will be served by this Test object that will keep providing the next question. If i had not used this approach i would have to query the database for every question. Have i used the correct approach? Are there any other approaches possible.
2. In my database i have three related tables, i need to access data from all the three related tables namely Subject_Master, Question_Master, Chapter_Master. since the test generated will have mixed questions from three subject therefore resultset would include subject code, chapter Code, question code. Because every chapter can have several question my resultset would look something like this
QID------QDESC-----CHID----SID
____________________________
1 ---------abc---------NWL-----PHY
2 ---------def---------CGM------MTH
3 ---------sdf ---------CGM-----MTH
4 ---------jkl ---------OPT------PHY
5 ---------tyu ---------THC------CHM
6 ---------fgd---------CGM------MTH
7 ---------fwr----------NWL------PHY
8 ----------ghi----------THC------CHM
.
.
_____________________________
PHY - Physics, CHM - Chemistry, MTH - Math
here we can see that i am getting multiple results for the questions from each chapter although i need a single question from every chapter in any subject. Here i could have fired a seperate query for finding a single question randomly from every chapter in the database and then adding that question to the Test. But i prefer to fire a single Query to find all the question from all the chapters from the subjects and then filter this resultset to select randomly a questions from each chepter to add it to the Test. In simple words what i am doing is instead of firing several Queries and doing the random selection in the database i am designating this task in the application. I feel we must refrain from puuting too much responsibility to the database if it can be done through the application. Is my approach correct ? what are the other possible solutions ?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |