Re: Primary key inheritance problem

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: Primary key inheritance problem
Дата
Msg-id 1093804499.29613.361.camel@linda
обсуждение исходный текст
Ответ на Re: Primary key inheritance problem  ("Matthew M Davis" <mmd@teledavis.com>)
Список pgsql-general
On Sun, 2004-08-29 at 18:07, Matthew M Davis wrote:
> On Sunday 29 August at 12:34pm, Oliver Elphick had this to say:
>
> > Primary and foreign key constraints are not inherited.  This is a defect
> > in the current system.
>
> It almost seems like a FEATURE to me, since it creates a different and
> easy way to create one-to-many relationships.  But I didn't use it,
> since the documentation says this is a Bad Thing that may be fixed
> some day.  If the child table inherits the primary key constraint from
> the parent, why not just put it in the same table?

If you understand inheritance from the point of view of object-oriented
programming, you want to be able to have a hierarchy where the top level
has characteristics which are extended further down.

So all mammals are animals and all dogs are mammals, and all three
groups share common characteristics which are properties of the parent
class.  But mammals have characteristics which are not applicable to all
animals and so are not appropriate to the parent class; similarly, dogs
have properties which are not common to all mammals.

Now one particular animal is either a mammal or it is not, and if it is,
it is either a dog or it is not.  What it is governs which class it
belongs to in the hierarchy.  Nevertheless, I may want to know about the
characteristics of animals without enquiring into the particular
characteristics of mammals; in that case an enquiry on the top-level of
the hierarchy is appropriate and will gather all information about all
animals.  If I want to make a further enquiry about properties peculiar
to mammals, it is appropriate to start my enquiry at that level in the
hierarchy.  However a particular animal can only be in one particular
class, therefore it would be preferable for the primary key to extend
over the whole hierarchy.

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "Preach the word; be instant in season, out of season;
      reprove, rebuke, exhort with all longsuffering and
      doctrine."          II Timothy 4:2


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

Предыдущее
От: "Matthew M Davis"
Дата:
Сообщение: Re: Primary key inheritance problem
Следующее
От: Hervé Piedvache
Дата:
Сообщение: RSS Feeds are dead on Web site