Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Foreign key

6 views
Skip to first unread message

Peter Kirk

unread,
Mar 10, 2005, 4:19:28 AM3/10/05
to
Hi

this is a general question about relational databases, not specific to
Oracle (I think), so if there is a better place to ask then please let me
know.

I have a question about constraints/foreign-keys.

For example:

I have table A and table B.
Table A has a foreign-key which points to a record in table B.

Is it possible to define this foreign-key so it can either be "null" (that
is, there is no related record in table B), or (if it has a value) then it
points to an existing record in table B.

It seems to me I can only define a foreign-key in table A so it must point
to an existing record in table B - it cannot be "null". I can just not
define a foreign-key at all - but then I cannot be sure that if there is a
value it actually points to a record in table B.

Hope you can understand my question.

Thanks,
Peter

Valentin Minzatu

unread,
Mar 17, 2005, 6:53:23 AM3/17/05
to
Hi Peter,

If your column in table A allows for null values, then you should be fine:
you can add records in A with a null value for the reference column and have
no "master" record in table B.

Valentin Minzatu
v.a.l.e.n.t.i.n.m.i.n.z.a.t.u@y_a_h_o_o.c_o_m


"Peter Kirk" <peter_n...@thisisciberus.dk> wrote in message
news:4230...@news.wineasy.se...

0 new messages