Question on "best practise" for SELECTS on inherited tables

From: Hubertus Freiherr von F?uerstenberg <hubertus(dot)fuerstenberg(at)ise(dot)fraunhofer(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Question on "best practise" for SELECTS on inherited tables
Date: 2009-12-08 15:30:01
Message-ID: 4B1E70F9.4040601@ise.fraunhofer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)fuerstenberg(at)ise(dot)fraunhofer(dot)de
http://www.ise.fraunhofer.de

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2009-12-08 15:57:04 Re: LDAP configuration changes in 8.4?
Previous Message Glyn Astill 2009-12-08 15:28:25 LDAP configuration changes in 8.4?