Foreign Key
Foreign Key
От:
Frederic.Boucher@FRY.desjardins.com
Дата:
Hello everyone, I would just like to know if the Foreign key constraint feature should be a one of a near release... Any idea? Thanks
Re: [GENERAL] Foreign Key
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
> > > > Hello everyone, > > I would just like to know if the Foreign key constraint feature should be a one > of a near release... Any idea? Planned for 6.6, due in a few months. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: [GENERAL] Foreign Key
От:
Howie <caffeine@toodarkpark.org>
Дата:
On Tue, 5 Oct 1999 Frederic.Boucher@FRY.desjardins.com wrote: > Hello everyone, > > I would just like to know if the Foreign key constraint feature should be a one > of a near release... Any idea? for now, refint ( $PGSQL_SRC_ROOT/contrib/spi/ ) is what one should be using for foreign keys. requires two triggers, one on the parent and one on the child. works nicely. --- Howie URL: http://www.toodarkpark.org "Just think how much deeper the ocean would be if sponges didn't live there."
Re: [GENERAL] Foreign Key
От:
Herouth Maoz <herouth@oumail.openu.ac.il>
Дата:
At 01:10 +0200 on 06/10/1999, Howie wrote: > for now, refint ( $PGSQL_SRC_ROOT/contrib/spi/ ) is what one should be > using for foreign keys. requires two triggers, one on the parent and one > on the child. works nicely. Does it? I was under the impression that it supported cascading deletes but not cascading updates. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
Re: [GENERAL] Foreign Key
От:
"Csehi Andras" <acsehi@qsoft.hu>
Дата:
5 Oct 99,-kor Bruce Momjian wrote: > > Hello everyone, > > > > I would just like to know if the Foreign key constraint feature should be a one > > of a near release... Any idea? > > Planned for 6.6, due in a few months. And the INNER, OUTER JOIN statements? Bye: Andrew Csehi Csehi András acsehi@freemail.c3.hu, acsehi@qsoft.hu (1) 209-6651, (30) 229-4413
Re: [GENERAL] Foreign Key
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
[Charset ISO-8859-1 unsupported, filtering to ASCII...] > 5 Oct 99,-kor Bruce Momjian wrote: > > > > Hello everyone, > > > > > > I would just like to know if the Foreign key constraint feature should be a one > > > of a near release... Any idea? > > > > Planned for 6.6, due in a few months. > > And the INNER, OUTER JOIN statements? > We _think_ that will be in 6.6. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: [GENERAL] Foreign Key
От:
Howie <caffeine@toodarkpark.org>
Дата:
On Wed, 6 Oct 1999, Herouth Maoz wrote:
> At 01:10 +0200 on 06/10/1999, Howie wrote:
>
>
> > for now, refint ( $PGSQL_SRC_ROOT/contrib/spi/ ) is what one should be
> > using for foreign keys. requires two triggers, one on the parent and one
> > on the child. works nicely.
>
> Does it? I was under the impression that it supported cascading deletes but
> not cascading updates.
CREATE SEQUENCE employee_seq START 1 INCREMENT 1;
CREATE SEQUENCE expense_seq START 1 INCREMENT 1;
CREATE TABLE employee
(
emp_id int4 not null default nextval('employee_seq'),
emp_name varchar(30) NOT NULL,
PRIMARY KEY (emp_id)
);
CREATE TABLE emp_expense
(
emp_id int4 not null,
expense_id int4 not null default nextval('expense_seq'),
descr varchar(100) NOT NULL,
ondate date not null,
primary key (expense_id)
);
CREATE TRIGGER expense_empid_fk
BEFORE INSERT OR UPDATE ON emp_expense
FOR EACH ROW
EXECUTE PROCEDURE check_primary_key('emp_id', 'employee', 'emp_id');
CREATE TRIGGER employee_empid_propk
AFTER DELETE OR UPDATE ON employee
FOR EACH ROW
EXECUTE PROCEDURE check_foreign_key( '1', 'cascade', 'emp_id',
'emp_expense', 'emp_id');
----
caffeine=> select * from employee;
emp_id|emp_name
------+--------
2|Myself
(1 row)
caffeine=> select * from emp_expense;
emp_id|expense_id|descr | ondate
------+----------+-------+----------
2| 1|Test |10-06-1999
2| 2|Test #2|10-06-1999
(2 rows)
caffeine=> update employee set emp_id=5;
UPDATE 1
caffeine=> select * from emp_expense;
emp_id|expense_id|descr | ondate
------+----------+-------+----------
5| 1|Test |10-06-1999
5| 2|Test #2|10-06-1999
(2 rows)
caffeine=> select version();
version
--------------------------------------------------------
PostgreSQL 6.5.0 on i686-pc-linux-gnu, compiled by egcc
(1 row)
---
Howie URL: http://www.toodarkpark.org
"Just think how much deeper the ocean would be if sponges didn't live there."