Question on "best practise" for SELECTS on inherited tables - Mailing list pgsql-general

From Hubertus Freiherr von F?uerstenberg
Subject Question on "best practise" for SELECTS on inherited tables
Date
Msg-id 4B1E70F9.4040601@ise.fraunhofer.de
Whole thread Raw
Responses Re: Question on "best practise" for SELECTS on inherited tables  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
Hello,

please consider the following exemplary setup:

I want to store information on people in a database. People can be
either internal (staff) or external (company contacts, etc.). The idea
was to use one table for all people and have the tables that store
specific information inherit from it.

CREATE TABLE people (
     id SERIAL PRIMARY KEY,
     name VARCHAR(128),
     given_name VARCHAR(128),
     internal BOOLEAN DEFAULT TRUE
);

CREATE TABLE internal_people (
     uid VARCHAR(8),
     role VARCHAR(32)
) INHERITS (people);

CREATE TABLE external_people (
     company INTEGER REFERENCES companies(id)
);

What would be the best way to select a person from table people and
depending  on "internal" have the information from internal_people or
external_people displayed as well?

All the best,

Hubertus
--
Hubertus von Fuerstenberg
Commercial and Technical Services / IT
Fraunhofer-Institut fuer Solare Energiesysteme ISE
Heidenhofstrasse 2, 79110 Freiburg, Germany
Phone: +49 (0) 7 61 / 45 88-0 Fax: +49 (0) 7 61 / 45 88-90 00
hubertus.fuerstenberg@ise.fraunhofer.de
http://www.ise.fraunhofer.de



pgsql-general by date:

Previous
From: Glyn Astill
Date:
Subject: LDAP configuration changes in 8.4?
Next
From: Magnus Hagander
Date:
Subject: Re: LDAP configuration changes in 8.4?