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: Foreign key to multiple tables ???

Re: Foreign key to multiple tables ???

From: N Prabhakar <prabhs_at_po.pacific.net.sg>
Date: 1996/11/20
Message-ID: <56v283$72p@newton.pacific.net.sg>#1/1

kirmo.uusitalo_at_comptel.fi (Kirmo Uusitalo) wrote:
>Hi,
>
>Suppose I want to create three tables: one "child" table and two master
>tables:
>
>
>create table customer_account (customer_id number(9),
> account_class varchar2(10),
> account_type number(2),
> ...)
>
>create table savings_account_types(account_type number(2),
> ...)
>
>create table check_account_types (account_type number(2),
> ...)
>
>In the child table customer_account field account_class implies whether
>account_type refers to savings_account_types (account_class='savings') or
>check_account_types (account_class='check').
>

Hi there,

If you need complete data integrity, then have 2 columns in child table. Only one can have a value at any time.

If you implement this approach, you can create FOREIGN key pointing 1st column to MASTER TABLE 1 and 2nd column to MASTER TABLE 2. There will be no compromise on data integrity (except NULL values).

If the child table does not hold huge records or if the column which you need to store is small (in terms of data length) then this option is viable.

Regards

N.Prabhakar Received on Wed Nov 20 1996 - 00:00:00 CST

Original text of this message

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