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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 foreign key relationship from two or more tables

Author  Topic 

jonekim
Starting Member

35 Posts

Posted - 2012-04-23 : 20:28:02
student table:
stud_name
stud_regNum(PK)

course table:
course_code(PK)
course_name

this relationship is many to many so I created a bridge table.

marks table
stud_regNum(FK)
course_code(FK)
marks

when I draw database diagram, it do not show foreign key relationship between these three tables
only the relationship b\n any two tables is shown. why is it so?

do ms sql server 2005 do not allow foreign key relationship from two or more tables?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-04-23 : 22:04:33
Script out the foreign keys for us so that we can see how you have it configured.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

vinu.vijayan
Posting Yak Master

227 Posts

Posted - 2012-04-27 : 06:50:27
quote:
Originally posted by jonekim

student table:
stud_name
stud_regNum(PK)

course table:
course_code(PK)
course_name

this relationship is many to many so I created a bridge table.

marks table
stud_regNum(FK)
course_code(FK)
marks

when I draw database diagram, it do not show foreign key relationship between these three tables
only the relationship b\n any two tables is shown. why is it so?

do ms sql server 2005 do not allow foreign key relationship from two or more tables?



stud_regNum(FK) Refernces stud_regNum(PK) which is in "StudentTable" and course_code(FK) References course_code(PK) in "Course Table".
Right???

quote:
only the relationship b\n any two tables is shown


This is because at a time there is only relation between two tables:
1. "marks table" is related to "StudentTable" via stud_regNum(FK).
2. "marks table" is related to "Course Table" via course_code(FK).

The tables "StudentTable" & "Course Table" are separate Master Tables and are not related to each other.
This is why a three way Relationship is not shown in th Database Diagram.

N 28° 33' 11.93148"
E 77° 14' 33.66384"
Go to Top of Page
   

- Advertisement -