954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help with database linking!

First of all, this is NOT for homework, so if you help, you WON'T be doing my homework for me! :lol: I am trying to create a quiz site for my school. I want the trachers to be able to create quizzes for their students. They will fill out a form to do so. However, with each new question they create, they need to associate it with a "QuizID", which will associate each question with their new quiz. How should i go about preventing duplicate "QuizIDs" so that questions and quizes don't merge, due to two identical "QuizIDs"? thanks! P.S. I am programming in Visual Basic.NET

Mikecool509
Newbie Poster
21 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

I am not quite sure of your requirements.
You want a quiz and it has an id (say QZ1) and then you want a question with an id (say Q1) and then to associate it to the quiz... but you want to make sure that this question hasnt already been used?

If that is the case you need an association table (which i would use anyway so you could resuse the questions in other quizzes - ie you have a bank of questions and pull them out for a quiz - which is how most exams work anyway). So you have a table of quizzes each with their own id and a name (or whatever you need) and a table of questions (and probably a table of answers to the questions). Then a quiz-question association table which will have two columns (usually) one for the quiz id and one for the question id. Then make the two columns a primary key (that is the two columns together make one primary key). That forces the quizid, question id combination to be unique (and also fast for you searches etc). That way a question can only appear once in a quiz but can be in in other quizzes too as the quizid question id combination will be different.

If this is a bit confusing let me know and i will try and clarify

f1 fan
Posting Whiz in Training
279 posts since Jan 2006
Reputation Points: 26
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You