Home » RDBMS Server » Server Administration » Problem with foreign key to a unique key
Problem with foreign key to a unique key [message #373476] Wed, 18 April 2001 13:50 Go to next message
Colin
Messages: 6
Registered: April 2001
Junior Member
I posted this message in Oracle Server Board early, but realise that this board is more suitable for it.

My problem can be illustrated by using the following example:

create table orders (
id number primary key,
orderNum vchar2(12),
constraint unq_ord unique (id, orderNum)
)

create table orderitem (
id number primary key,
orderId number,
orderNum vchar2(12),
constraint fk_oi foreign key (orderId, orderNum)
references orders(id, orderNum)
)

You can notice that ORDERITEM references ORDERS using the unique key in that table. The problem is caused by this, but I have no choice in my application.

Ok, the problem is: if I update the ORDERS.orderNum in transaction 1, and I start transaction 2 to insert/delete one row of ORDERITEM, the second process is block until I commit/rollback in transaction 1, even though the update in ORDERITEM has no conflict with that in ORDERS.

If the foreign key is defined to the primary key, there is no such problem. This certainly will be a big problem in production. Anybody knows how to solve it?

Thanks.
Re: Problem with foreign key to a unique key [message #373485 is a reply to message #373476] Thu, 19 April 2001 01:46 Go to previous messageGo to next message
Aparna
Messages: 9
Registered: April 2001
Junior Member
I would definetley like to know the answer for this problem.
would welcome answers to my id
Re: Problem with foreign key to a unique key [message #373507 is a reply to message #373476] Thu, 19 April 2001 21:47 Go to previous message
Colin
Messages: 6
Registered: April 2001
Junior Member
Please see the posts in the Oracle Server Forum.
Previous Topic: Re: Query a column and remove everything after the space
Next Topic: top rows
Goto Forum:
  


Current Time: Mon Jul 01 15:58:16 CDT 2024