SQLTeam.com | Weblogs | Forums

1 primary key Vs 2 Foreign keys


#1

Hi,

I have 2 tables TableA and TableB..

TableA

PatID (PK)
PatType
OrgID (FK)
OrgLocID (FK)

TableB

OrgID (PK)
OrgName
OrgAddress

I want to create a relationship where by I have 1 PK linking to 2 FKs, as shown above.

How can I achieve this ?

Thanks


#2

so let's see your create table statements! Two FKs is no harder than one.


#3
ALTER TABLE TableA ADD 
    CONSTRAINT TableA__FK_OrgID FOREIGN KEY REFERENCES TableB ( OrgID ),
    CONSTRAINT TableA__FK_OrgLocID FOREIGN KEY REFERENCES TableB ( OrgID )