Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Quasi Foreign Key

Re: Quasi Foreign Key

From: David Grzebien <dgrzebie_at_columbus.rr.com>
Date: Wed, 01 Nov 2000 00:23:19 GMT
Message-ID: <39FF63C8.5575A138@columbus.rr.com>

You will not be able to create a foriegn key constraint from the child table to the parent table. The reason is the foreign key must contain the primary key columns from the parent table.

In response to your statement "the problem is that the value "null" in the child table's column is not an..." is not a problem at all. You can still create a foreign key from the child table even if the value is null. Oracle will not validate the entry since Oracle considers a "null" value as an unknown. Try it and you will see.

The only real way to do this is by a trigger as was mentioned earlier.

Dave Grzebien
Oracle Certified DBA

Steve Long wrote:

> i have the following scenario and could use some assistance.
>
> parent table has composite primary key consisting of three columns.
>
> child table has a column which has a foreign key to parent table using the
> first column of the parent table's composite primary key. however, the
> child table's column may be null, but if it is not null it's value must be
> present in the parent table's column.
>
> the problem is that the value "null" in the child table's column is not an
> allowable value in the parent table's column since in the parent table this
> column is part of the primary key.
>
> any suggestions on how to implement this?
Received on Tue Oct 31 2000 - 18:23:19 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US