Thread: Foreign Key ??

Foreign Key ??

From
David Jackson
Date:
Good-day,
How are foreign keys implemented in PostgresSQL ?
I tried using the following statment:
CREATE TABLE orders(
    order_no    int     primary key,
    client_name    char(30),
    CONSTRAINT  NAME_FK FOREIGN KEY (client_name)
        REFERENCES client(client_name)
);
This results in FUNCTION NOT IMPLETEMENTED error.

Thanks for you time
David Jackson


Re: [SQL] Foreign Key ??

From
Fabio Mancinelli
Date:
On Sun, 8 Nov 1998, David Jackson wrote:

>     CONSTRAINT  NAME_FK FOREIGN KEY (client_name)
>         REFERENCES client(client_name)
> );
> This results in FUNCTION NOT IMPLETEMENTED error.
>
Yes, that's true. There is no built-in referential integrity in
PostgresSQL. Anyway there are two "external" functions in the contrib/spi
directory which implement the referential integrity.
You can use these functions via triggers.

All the docs and the sources are in the contrib/spi dir in the source code
distribution (v6.4), I don't remember if they are also available in the
v6.3 source code distibution.

Bye.

------------------------------------------------------------------------------
 Greetings from Fabio Mancinelli   E-Mail : mancinel@univaq.it
 Computer Science Student                   xenon@olografix.org
 University of L'Aquila               WWW : http://univaq.it/~mancinel
 (PGP Public Key available)                 http://www.olografix.org/xenon