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