Re: Newbie Inheritance Question - Mailing list pgsql-general

From Edwin Grubbs
Subject Re: Newbie Inheritance Question
Date
Msg-id Pine.LNX.4.30.0106221302150.25688-100000@zamboni.wc6.rackspace.com
Whole thread Raw
In response to Newbie Inheritance Question  (David Wheeler <David@Wheeler.net>)
Responses Re: Newbie Inheritance Question  ("Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu>)
List pgsql-general
Unless you have some kind of development environment that requires it, you
should avoid using inheritance. Besides the fact that I recently asked on
the list on how to get indexes to work when selecting from all the
inherited tables at once and still have not received an answer,
inheritance is just a bad way to structure your database since it makes it
a huge pain to manage which entry should be in which table. One of the
huge risks of using inheritance as a distinguishing attribute is that if
you need to move rows between tables, you have to wrap the move in a
transaction to make sure you don't delete something that didn't get moved
probably or that you don't have the same row in two different tables.

Instead of inheritance, you should have a table such as person_type, which
describes the category that they are in which you were formally
distinguishing between using inheritance. If you need to add additional
columns just for one category, this can be done easily with an extra
table, and you can always use views if you don't want to join tables
manually a lot or if you need old code to remain compatible with the new
layout. By having a column as your category attribute, you also benefit
from being able to easily select from child-1 and child-2 without
selecting rows from the parent table or child-3.

-Edwin

On Fri, 22 Jun 2001, David Wheeler wrote:

> Hi All,
>
> Can anyone tell me now I might extend an existing record in a parent table
> to have values in an inherited table? An example would be a table of all
> people (person), and a table of users (usr) that inherits from person. Say
> there's an existing record in person, and I want to use that same record
> to make them a member of the usr table, as well. Is this possible, other
> than by deleting the record from person and re-inserting it into usr?
>
> Thanks,
>
> David
>
>

--
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

mQGiBDj905MRBACm5QP3Z4mILmXUsLN8bnhDgoG6HQa4mn/wQsaLApOwN5/802Y8
5yAIZiWH4I2iMqZdqwBrnQXQsoRBWIVHueYoVbtLcLdelt2bW2YI16JYkOMVOQ5i
EBd1gP93hsl6Te4sOPQ/X2Oms+MYjMW7u5HPQIv6lIwgjE7MIz19/b+Vb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Dt5NR7muZopEx99W7vHH0gxqXyzcAnkMFcbhdp
86jtot+w1BOa26wjj0keQi0EhbXr5GOTMaHk2avXhzfLYvfVknjYCtScw+4tvtfi
n2e4NGzXQxXejHV9uPdDEin7ts1OjmSwB1oXsYVjAU7ZhHQOwDlw5BoUGAorMY0i
fHtx16IPwsD+06HFoz9W36iBXuR8GmFXBOiZv8fuMHhTPlOIRgQYEQIABgUCOP3U
HQAKCRDXgAoO6t/5USJkAKDOQAywN/ZLijImMIge4ylut9xYyACggOO0sp8QS/ea
vFDsdhwocmVhGbo=
=qOGJ
-----END PGP PUBLIC KEY BLOCK-----


pgsql-general by date:

Previous
From: will trillich
Date:
Subject: Re: where's the reference to a view, here?
Next
From: Stephan Szabo
Date:
Subject: Re: Rerefences to derived rows