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 2000 Forums
 SQL Server Development (2000)
 PK , FK combination

Author  Topic 

shaban
Starting Member

1 Post

Posted - 2010-02-26 : 08:09:01

hello, i am SQL beginer and i want to know

Is it correct for one attribute in a table to be PK of a table and FK at the same time ?

hello

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-26 : 08:19:56
nope. FK of a table would be PK column of another table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2010-03-01 : 01:36:28
Well actually it can sort of.
Consider a many to many:

TableA
idA
stuff

TableB
idB
stuff

TableAtoTableB
idA
idB
stuff

In TableAtoTableB both idA and idB are FKs and PKs, though admittedly individually not the complete PK.

Also where there is a 1 to 1 relationship you may well have the common key as a PK then also as a FK in one of the tables to make sure it actually referred to something.
Go to Top of Page
   

- Advertisement -