Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Bridging table issue

Author  Topic 

sqlontherun101
Starting Member

16 Posts

Posted - 2009-06-28 : 01:43:10
hi,

I have two entities Question and Answer. Business rule says that
1. A Question can have many answers (4 answers) PK- QID
2. An ANswer can be in Many Questions PK - AID

Therefore i have added a bridging table called "QuestionwithAnswers"
and i have added "QID" and "AID" as PK (composite) for "QuestionwithAnswers".

Assume i have to search for a Question and it's answers,
How do i perform that using those three tables?

"Question" table has the following attributes:
QID
Statement
correctAnswer

"Answer" table has the following attributes:
AID
Statement

"QuestionwithAnswers" table has the following attribute:
AID
QID

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-28 : 01:54:06
use INNER JOIN

select *
from QuestionwithAnswer qa
inner join Question q on qa.QID = q.QID
inner join Answer a on qa.AID = a.QID



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -