Re: inheritance

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: inheritance
Дата
Msg-id 1045428445.30277.59.camel@linda.lfix.co.uk
обсуждение исходный текст
Ответ на inheritance  ("Felipe Schnack" <felipes@ritterdosreis.br>)
Список pgsql-general
On Thu, 2003-02-13 at 12:04, Felipe Schnack wrote:
>   Hi all...
>   I'm starting to play with pgsql inheritance features and I just wondered a
> specific situation where I wouldn't have any idea of how to use it. Let's say
> I create these tables:
>   create table persons (id serial primary key);
>   create table students (number int) inherits persons;
>   create table emplyees (anothernumber int) inherits persons;
>   Let say I can have a person that is a student and is a employee of the
> company... how I would insert its data in my database??

You can create another table:
    create table student_employees (PRIMARY KEY (id)) inherits
(students, employees);

Beware, that you have no overall uniqueness check on the id field; and
the primary key constraint is not inherited - it must be repeated for
each table.

On the other hand there may be better ways of solving this particular
problem, such as using foreign keys instead.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "But as many as received him, to them gave he power to
      become the sons of God, even to them that believe on
      his name"        John 1:12


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

Предыдущее
От: Dima Tkach
Дата:
Сообщение: Re: Index not used with IS NULL
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: accessing currval(), How? ... Trigger? I think...???