Re: [GENERAL] Implementing hierarchy

From: <patrickdlogan(at)home(dot)com>
To: pgsql-general(at)hub(dot)org
Subject: Re: [GENERAL] Implementing hierarchy
Date: 1999-06-03 22:59:11
Message-ID: 14167.2065.219096.997269@c837917-a.potlnd1.or.home.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rob Walker writes:
> > I am trying to write code to access a product catalog (more as a learning
> > exercise than anything else) and need to implement some sort of searchable
> > hierarcy. For example:
> >
> > Computer Hardware (toplevel)
> > Hard Drives
> > Internal
> > SCSI
> > Fast SCSI
> > Wide SCSI
> > SCA
> >
> > Assuming these 'categories' are all in the same table as follows:
> >
> > prkey (primary key)
> > descr varchar
> > parent (for subcategories, toplevel parent is 0)
>
> I don't know if there is a 'right' way to do this, but I have done something
> similar having an extra table that contains a tuple listing (node, ancestor)
> pairs. This is kept in sync with the main table using a couple of triggers.
> The code is at the end
>
> A sequence is used for the primary key in the main table, and the hierarchy
> is then implicit since you can't create a child before the parent (at least
> my application doesn't let you move an existing child to another parent).

Here is a web page that may help. It explains something along the same
lines.

http://www.dbmsmag.com/9809d05.html

--
Patrick D. Logan mailto:patrickdlogan(at)home(dot)com

Browse pgsql-general by date

  From Date Subject
Next Message Chris Bitmead 1999-06-04 00:16:24 Re: [GENERAL] Parallelizing PostgreSQL for Cluster
Previous Message doctor 1999-06-03 21:07:32 Re: [GENERAL] RE: [PORTS] AIX-4.2.1 binaries ? more info. PLEASE