muneerz
asked on
quiz query
please check and help me to get out
I have a task where i have to create a contest page
i have already created a table called tblcontest
tblcontest have contestid which is a primary key
2) i have tblquestion where iam storing the questions and these questions will be related to contest id
hence in tblquestion i have created primary key as questionid and foreignkey as contestid
3) i have tblanswers which is storing 4 choice answers related to question id
in tblanswers i have answerid as primary key and foreignkey as question id
4) the tblquestionanswers is having the questionid and answerid
the question id is a question and answerid is a answer to the question
Now in asp.net page iam unable to call three questions with their multiple choice questions
i mean to say the quiz will have 3 question with multiple choice answers
each question will have 4 answers
below to this question i have also user info to store
so i have created a tbluser with userid as a primary key
now, please help me how to fetch the data in asp.net page where i should be able to display 3 questions with 4 choice answers to each question
also the moment user submit the answers by clicking the submit button it shld store the user info as well as his answers history and later i should be able to see who is the winner or loser three correct quesion answers will make him winner
Didn't quite finish.
I'd also have:
tblCorrectAnswer
QuestionID (PK,FK)
AnswerID (FK)
I'd also have:
tblCorrectAnswer
QuestionID (PK,FK)
AnswerID (FK)
ASKER
I have created a database on my design and it is correct upto my knowledge, only the part along wuth userid how can i store the user details with correct answers,i want that code in asp.net code
Like always, there are many ways. But I would create a stored procedure to perform the insert and then invoke it from an ado command object, passing the questionID, UserI, and AnswerID as parameters. You can find many examples on the web for how to call a stored procedure from VB or C# code behind an asp form.
ASKER
dear dg mg iam not able to find the solution in web, hence i have written to this forumn expecting a code help , please check you could help me in coding part
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Specification 3 implies: an answer belongs to a single question
Specification 4 implies: an answer may belong to many questions
In other words, you have two ways to find the answers to a question. One is to join tblAnswer to tblQuestion. The other is to join tblQuestionAnswer to tblQuestion.
So...it's not clear to me why you have tblQuestionAnswers in your design. In fact, if you ALWAYS, ALWAYS, ALWAYS have exactly 4 Answers to EVERY question, it is not clear to me why you have tblAnswers in your design. (Although, the two absolutes in that assertion do cast come reservations).
Really, I'd suggest this design:
tblContest
ContestID (PK)
tblQuestion
QuestionID (PK)
tblContestQuestion (allows same question to be used in multiple contests)
ConstestID (PK, FK)
QuestionID (PK, FK)
tblAnswer
QuestionID (PK,FK)
AnswerID (PK)