One FOREIGN KEY refrences a Table with two Primary Keys

One FOREIGN KEY refrences a Table with two Primary Keys

Post by Stev » Thu, 11 Dec 2003 18:23:27



How can we create a table with one FOREIGN KEY column that refrences a table
with two or more PRIMARY KEYS? (I need just one of the primary keys for
referencing)
 
 
 

One FOREIGN KEY refrences a Table with two Primary Keys

Post by Jacco Schalkwij » Thu, 11 Dec 2003 18:45:05


A table can only have one Primary Key, so I don't really see your problem.

--
Jacco Schalkwijk
SQL Server MVP


Quote:> How can we create a table with one FOREIGN KEY column that refrences a
table
> with two or more PRIMARY KEYS? (I need just one of the primary keys for
> referencing)


 
 
 

One FOREIGN KEY refrences a Table with two Primary Keys

Post by Vishal Parka » Thu, 11 Dec 2003 18:41:10


Steve,

Quote:> with two or more PRIMARY KEYS? (I need just one of the primary keys for

I guess you mean to say a primary key with more than one column that is
composite primary key. Also if this is the case then you can not create a
referential integrity constraint that is referencing to only one column of the
primary key. The foreign key should reference all the columns of the primary
key.

--
- Vishal