Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help! defining referential integrity
On 24 Oct 1997 17:16:59 GMT, earvin_at_omega.uta.edu (Earvin C. Lim) wrote:
>
>Hi there!
>
>I have the following questions and hope someone would help me:
>
>When we create tables, how do we define referential integrities?
>
For example:
create table parent_table (
parent_id number, some_data varchar2(30), constraint parent_pk primary key (parent_id) ); create table child_table ( parent_id number, child_id number, some_more_data varchar2(30), constraint child_pk primary key (parent_id,child_id), constraint child_has_parent foreign key (parent_id) references parent_table );
The basic rule is that the fields of the foreign key in your referencing table must match the primary key fields in the referenced table.
Hope this helps.
Jonathan