Home » RDBMS Server » Server Administration » composite primary keys
composite primary keys [message #372047] Fri, 05 January 2001 16:13 Go to next message
dan kim
Messages: 3
Registered: January 2001
Junior Member
got a question. i have a single column primary key trying to reference a table that has a 2 column composite primary key. when i use the reference command when creating the table, i get the error:

ORA-02256 number of referencing columns must match referenced columns

Cause: The number of columns in the foreign-key referencing list is not equal to the number of columns in the referenced list.

Action: Make sure that the referencing columns match the referenced columns.

does this mean that a parent key must be composite to reference a child composite key? is there a way to reference my single column primary key parent table to a child composite key table?
Re: composite primary keys - wrong way around? [message #372063 is a reply to message #372047] Mon, 08 January 2001 14:31 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
It sounds like you could have the references command the wrong way around? Remember that the references command applies to the Child table, specifying what the Parent table is. Your 2 column composite table must be the child table, as it's PK can have the value from the single col PK column repeated.

e.g.
Order
1
2
3

Order_Item
1, a
1, b
2, a

Order_Item table references Order table. Do try to resolve this referential integrity, it is important.
Previous Topic: Re: Is JOIN a better choice over SUBQUERY ? Pl. expl.
Next Topic: SQL Loader Question - Keeping blanks as blanks instead of nulls
Goto Forum:
  


Current Time: Fri May 17 04:45:02 CDT 2024