Question on "best practise" for SELECTS on inherited tables

Поиск
Список
Период
Сортировка
От Hubertus Freiherr von F?uerstenberg
Тема Question on "best practise" for SELECTS on inherited tables
Дата
Msg-id 4B1E70F9.4040601@ise.fraunhofer.de
обсуждение исходный текст
Ответы Re: Question on "best practise" for SELECTS on inherited tables  (Merlin Moncure <mmoncure@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Glyn Astill
Дата:
Сообщение: LDAP configuration changes in 8.4?
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: LDAP configuration changes in 8.4?