Re: Unable to reference a composite key as FK

Re: Unable to reference a composite key as FK

 

  

Here you go. Tested in 9i rel 2 and 8.1.6.3

SQL> create table my_parent(c1 number, c2 number, c3
varchar2(10),constraint pk_my_parent primary key(c1,c2));

Table created.

SQL> alter table my_parent add unique(c1);

Table altered.

SQL> alter table my_parent add unique(c2);

Table altered.

SQL> create table my_child(c6 number references my_parent(c1)
2 ,c7 number references my_parent(c2)
3 )
4 /

Table created.

SQL>

HTH
GovindanK
Oracle Certified Professional(8,8i)
Brainbench Certified Master DBA


<-----Original Message----->
From: Kumar
Sent: 10/30/2003 8:04:04 PM
To: [Email Address Removed] Re: Unable to reference a composite key as FK

Dear friends,

I have encountered a problem in referencing a member of a composite key
as a FK in another table.

table A
c1,c2,c3,c4

tableB
c7,c8,c9

For 'tableA' I have a composite primary key on columns c1+c2.

I wanted to make a relationship(FK) for the 'c7' in 'tableB' with the
'c2' of 'tableA'. But it showed me an error
The columns in 'tableA' do not match an existing primary key or unique
constraint

Is this not allowed in relational databases? Somebody pls enlighten me
with the concept behind this.

Regards
Kumar

_______________________________________________________________
Get Your 10MB account for FREE at http://mail.arabia.com !
Access MILLIONS of JOBS NOW!
<http://ads.arabia.com/?SHT=text_email_english>
Oracle LazyDBA home page