Re: Referential Integrity

From: Sergey M <msu_at_pronto.msk.ru>
Date: Mon, 27 May 2002 11:48:33 -0700
Message-ID: <acsoh2$1r19$1_at_serv2.vsi.ru>


"surya" <sai_surya_mp_at_yahoo.com> wrote in message news:e4fde6e1.0205230059.20c7c9db_at_posting.google.com...
> I am having tow Tables like this.
>
> Table1(Id (Char),Name(Varchar))
> Table2(Name(Varchar))
>
> Primary Key is "Name" for both tables.
>
> My question is i want to maintain referential integrity between the
> above tables.
>
> Whenever i am updating a record of Table1 column "Id" with value "X" i
> need to delte the record in Table2.
>
> Can suggest a "Create table queries".
>
> Thanks in advance
> Surya

May be It is that you want:

create table table1(
name varchar2(10),
id char(10),
constraint PK primary key(name));

Create table table2(
name varchar2(10) primary key,
constraint FK foreign key(name) references table1 (name) on DELETE cascade);

Sergey M. Received on Mon May 27 2002 - 20:48:33 CEST

Original text of this message