Re: Referential Integrity

From: michael ngong <mngong_at_yahoo.com>
Date: 23 May 2002 08:55:40 -0700
Message-ID: <ecf365d5.0205230755.26d28a50_at_posting.google.com>


sai_surya_mp_at_yahoo.com (surya) 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

You can implement referential integrity by letting a foreign key reference a primary key.
This example might help clarify the point Table1

create table Miketable1(
name varchar2(10),
salary number,
constraint PK primary key(name));

Table Two

Create table Miketable2(
name varchar2(10),
location varchar2(13),
constraint FK foreign key(name) references Miketable1 (name));

Michael Tubuo Ngong(Sr DBA) Received on Thu May 23 2002 - 17:55:40 CEST

Original text of this message