On Fri, 2006-10-06 at 23:09 +0200, Ivan Sergio Borgonovo wrote:
> Is there any good documentation, example, tutorial, pamphlet, discussion... to exploit pg features to obtain
"polymorphic"behavior without renouncing to referential integrity?
>
> Inheritance seems *just* promising.
>
> Any methodical a approach to the problem in pg context?
>
I'm not sure if this answers your question, but here's how I do
inheritance in the relational model.
Just make a "parent" table that holds a more generic object like:
CREATE TABLE person (name TEXT PRIMARY KEY, age INT, height NUMERIC);
Then a "child" table like:
CREATE TABLE student (name TEXT REFERENCES person(name), gpa NUMERIC);
Every person, student or otherwise has a record in "person". If, and
only if, they are a student they have a record in the "student" table.
To select all people, select only from the "person" table. To select all
students, select from the join of the two tables.
Regards,
Jeff Davis