aspose file tools*
The moose likes JDBC and the fly likes Foreign key access problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Foreign key access problem" Watch "Foreign key access problem" New topic
Author

Foreign key access problem

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi,

I have two tables table1 and table2. I have 3 fields in each tables. I made two of the fields in table1 as composite primary key. Now, I want to make one among these fields as foreign key to table2. When I give like this and try to run, I'm getting an error like

SQL> Error Message: The Foreign Key TABLE1_0_SYSTEMNAMEDCONSTRAINT_TABLE2_FOREIGNKEY_NAME does not map to a primary key in table TABLE2. Each foreign key must reference a table that has a primary key made up of the same columns as specified in the reference list.


Here, I want to make that field(one among the composite primary key participants) as foreign key in my table2. Is it possible? If so how?


Thanks in advance,
Narendranath.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
138

Narendranath,
It is possible to do that. Do you have a one field primary key on table 2? Is it the same datatype?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Foreign key access problem
 
Similar Threads
How do I map this?
one-to-many mapping with table having no primay key
One - to -one mapping using non primary key
database design help needed
ID_NAME in two tables