From: | Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Foreign key |
Date: | 2000-01-29 18:58:46 |
Message-ID: | 20000129185846.A1121@quartz.newn.cam.ac.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)LNX(dot)3(dot)96(dot)991006152248(dot)8877H-100000(at)rabies(dot)toodarkpark(dot)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
>
> ************
>
From | Date | Subject | |
---|---|---|---|
Next Message | mp3_exchanger | 2000-01-30 02:30:58 | MP3Exchanger v1.13 New Internet utility. Use to exchange and locate binaries of any file format. |
Previous Message | Peter Eisentraut | 2000-01-29 16:58:51 | Re: [GENERAL] Quick function question |