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: Help! defining referential integrity

Re: Help! defining referential integrity

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 1997/10/26
Message-ID: <62u9rm$6ul@bgtnsc01.worldnet.att.net>#1/1

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



gennick_at_worldnet.att.net
http://home.att.net/~gennick Received on Sun Oct 26 1997 - 00:00:00 CDT

Original text of this message

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