Re: inheritance and primary/foreign keys - Mailing list pgsql-general

From Einar Karttunen
Subject Re: inheritance and primary/foreign keys
Date
Msg-id Pine.LNX.4.30.0103090919340.26024-100000@melkinpaasi.cs.Helsinki.FI
Whole thread Raw
In response to Re: inheritance and primary/foreign keys  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: inheritance and primary/foreign keys  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
On Wed, 7 Mar 2001, Stephan Szabo wrote:
>
> You cannot safely reference tops of inheritance trees under 7.0 or 7.1 and
> have it reference the trees.
>
Is there anyway to emulate this? I want to have several types of persons
which have varied and common data. How can I implement refences to a
person or a child table of person? Are there any problems with the parent
having a serial column? The index should be unique for all the children
too.

CRETE TABLE person (
    id    SERIAL,
    fname    varchar(15),
    lname    varchar(15),
    pwd    varchar(8)
);

CREATE TABLE teacher (
    uname     char(4)
) INHERITS (person);

CREATE TABLE admin (
    uname    char(8),
    type    integer
) INHERITS (person);

CREATE TABLE record (
    id    SERIAL,
    pid    integer REFERENCES person
);

- Einar Karttunen


pgsql-general by date:

Previous
From: will trillich
Date:
Subject: Re: explain -> how to optimize?
Next
From: "Eric G. Miller"
Date:
Subject: Re: inheritance and primary/foreign keys