Best practice on inherited tables

Поиск
Список
Период
Сортировка
От Frank Lanitz
Тема Best practice on inherited tables
Дата
Msg-id 519626C2.2030905@frank.uvena.de
обсуждение исходный текст
Ответы Re: Best practice on inherited tables  (Chris Travers <chris.travers@gmail.com>)
Re: Best practice on inherited tables  (Alfonso Afonso <aafonsoc@gmail.com>)
Re: Best practice on inherited tables  (Julian <tempura@internode.on.net>)
Список pgsql-general
Hi folkes,

I'm looking for a nice way to build this scenario:
I've got a lot of locations with some special types. For example I've
got workplaces, places like real laboratories and virtual places like
maybe parcel service. For each of the different types I need to store
some common attributes as well as some special ones. Having OOP in mind
I came to the point of inherit tables. so I've create something like
that (just a minimal example):

CREATE TABLE locations(
    id SERIAL PRIMARY KEY,
    name varchar(50)
);
CREATE TABLE workplaces(
    workers integer
) INHERITS (locations);

But now I got stuck with the primary key thing. As described in the
documentation it is not supported. And now I'm looking for the best way
on having at table workplaces also the unique constraint from locations
etc. so e.g. I can do something like that:

INSERT INTO workplaces (name, workers) VALUES ('My Place', 5);

having the incrementation and the uniqueness. I was thinking off
creating a number of triggers doing this for me but wondering whether
there might be a better way.

Cheers,
Frank

BTW: Using Postgres 9.2 and up


В списке pgsql-general по дате отправления:

Предыдущее
От: Cédric Villemain
Дата:
Сообщение: Re: [HACKERS] PLJava for Postgres 9.2.
Следующее
От: Chris Travers
Дата:
Сообщение: Re: Best practice on inherited tables