Received: from frithjof.reiner (qmailr@a110.dialin.tuwien.ac.at [192.35.240.120]) by hub.org (8.10.1/8.11.0) with SMTP id e9PG9gO98044 for ; Wed, 25 Oct 2000 12:09:43 -0400 (EDT) (envelope-from areiner@tph.tuwien.ac.at) Received: (qmail 1093 invoked by uid 500); 24 Oct 2000 21:15:10 -0000 From: "Albert REINER" Date: Tue, 24 Oct 2000 23:15:10 +0200 To: pgsql-sql , PostgreSQL-SQL Subject: Re: help on creating table Message-ID: <20001024231510.B1062@frithjof> Mail-Followup-To: pgsql-sql , PostgreSQL-SQL References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i In-Reply-To: ; from pgsql-sql on Fri, Oct 20, 2000 at 06:48:54PM +0800 X-Archive-Number: 200010/218 X-Sequence-Number: 1882 Saluton, this is easy: On Fri, Oct 20, 2000 at 06:48:54PM +0800, pgsql-sql wrote: ... > NODE1 > + --- NODE1_1 > + --- NODE1_2 > | + --- NODE1_2_1 > + --- NODE1_3 create table n (id int4, parent int4, data text); insert into n (id, data) values (1, 'node 1'); insert into n (id, parent, data) values (2, 1, 'node 1.1'); insert into n (id, parent, data) values (3, 1, 'node 1.2'); insert into n (id, parent, data) values (4, 3, 'node 1.2.1'); insert into n (id, parent, data) values (5, 1, 'node 1.3'); (you will probably want to use a serial for id, etc.) The idea is to store each node in a row, and to store both the row's id and the id of the parent node in it. When there is no parent node (your node NODE_1), parent is NULLL. HTH, Albert. -- -------------------------------------------------------------------------- Albert Reiner Deutsch * English * Esperanto * Latine --------------------------------------------------------------------------