Re: [GENERAL] Foreign key - Mailing list pgsql-general

From Patrick Welche
Subject Re: [GENERAL] Foreign key
Date
Msg-id 20000129185846.A1121@quartz.newn.cam.ac.uk
Whole thread Raw
In response to Foreign key  ("Patrick Welche" <prlw1@newn.cam.ac.uk>)
List pgsql-general
Just tried what I wrote ages ago below, and it now magically does work!
(Don't know since when)

Thanks Jan and co,

Patrick

On Wed, Dec 15, 1999 at 10:56:10PM +0000, Patrick Welche wrote:
> How do they work?
>
> Date: Wed, 6 Oct 1999 15:25:27 +0000 (GMT)
> Subject: Re: [GENERAL] Foreign Key
> Message-ID: <Pine.LNX.3.96.991006152248.8877H-100000@rabies.toodarkpark.org>
>
> I had a look at the above message which involved the refint contrib code. I
> thought the equivalent might be:
>
> CREATE TABLE employee
> (
>    emp_id serial primary key,
>    emp_name varchar(30) NOT NULL
> );
>
> CREATE TABLE emp_expense
> (
>    expense_id serial primary key,
>    emp_id int4 references employee match full on update cascade,
>    descr varchar(100) NOT NULL,
>    ondate date not null
> );
>
> insert into employee values (2,'Myself');
> insert into emp_expense values (1,2,'Test','10-06-1999');
> insert into emp_expense values (2,2,'Test #2','10-06-1999');
> select * from employee;
> select * from emp_expense;
> update employee set emp_id=5;
> select * from emp_expense;     -- hope emp_id magically changes to 5
>
> but obviously it can't be, as if I update employee, there is nothing in table
> employee to say "take a look at emp_expense and update emp_id over there".
> There only is something in emp_expense to say "check employee to see that
> emp_id here is valid".
>
> Anyone know of a tutorial/give me a hint?
>
> Cheers,
>
> Patrick
>
> ************
>

pgsql-general by date:

Previous
From: "Michael Black"
Date:
Subject: Re: how to: list of synonyms (Oracle)?
Next
From: Matthew Dormer
Date:
Subject: Error Updating Records.