Re: Tables Referencing themselves As Foreign Keys

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: "Tony (Unihost)" <tony(at)unihost(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tables Referencing themselves As Foreign Keys
Date: 2003-12-22 15:42:12
Message-ID: 1072107732.1966.28.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2003-12-22 at 05:57, Tony (Unihost) wrote:
> Hi,
>
> I'm still new to this so if I'm sounding dumb or my premise is flawed
> please forgive me. I have a DB design which contains a table which has
> categories, each category has a parent category, and is recursed until
> the top category is reached, in order to create breadcrumbs. Is there
> any problem with using foreign keys to reference the same table? So a
> when category is added the CatParent MUST be present as a CatID
>

Hmm... breadcrubs make me think you should look at using a nested set.
(Google "nested set celko" for more info)

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sai Hertz And Control Systems 2003-12-22 15:58:23 Unix 2038 And PostgreSQL
Previous Message scott.marlowe 2003-12-22 15:40:50 Re: Salvage older PostgreSQL data disk - help?