Re: root of parent-child table with NOT NULL

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: bill(at)wadley(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: root of parent-child table with NOT NULL
Date: 2002-05-02 22:40:45
Message-ID: web-1392303@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Bill,

> The question is: how do I add the first group? The very first group
> is
> the root group, and doesn't have a parent.
>
> My choices seem to be to either:
>
> - create the table without the constraint, add a group that will be
> the
> parent of all "root" groups, then add the constraint. The problem
> with
> this solution seems to be that dump and restores will be
> problematic.

This is exactly what you do, and pg_dump puts the constraints at the
end of the file to allow this sort of data load.

> So, kind sirs/madams, what am I missing?

Well, you should pick up a copy of Joe Celko's "SQL For Smarties" (2nd
Ed.), which has 20 pages on tree structures that will save you a lot of
headaches.

-Josh

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kristian Skrede Gleditsch 2002-05-02 23:37:39
Previous Message Tom Lane 2002-05-02 22:15:34 Re: ALTER TABLE table DROP CONSTRAINT problem