pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Albert REINER <areiner@tph.tuwien.ac.at>
To: pgsql-sql <pgsql-sql@fc.emc.com.ph>
To: PostgreSQL-SQL <pgsql-sql@postgreSQL.org>
Subject: Re: help on creating table
Date: Tue, 24 Oct 2000 23:15:10 +0200
Message-ID: <20001024231510.B1062@frithjof> (raw)
In-Reply-To: <fc.000f567200761eac000f567200761eac.761f09@fc.emc.com.ph>
References: <fc.000f567200761eac000f567200761eac.761f09@fc.emc.com.ph>

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                                   <areiner@tph.tuwien.ac.at>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------



view thread (2+ messages)

Message-ID: <20001024231510.B1062@frithjof>
Permalink:  ../20001024231510.B1062@frithjof/
Also on:    postgresql.org/message-id/20001024231510.B1062@frithjof

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: areiner@tph.tuwien.ac.at, pgsql-sql@fc.emc.com.ph
  Subject: Re: help on creating table
  In-Reply-To: <20001024231510.B1062@frithjof>
  References: <fc.000f567200761eac000f567200761eac.761f09@fc.emc.com.ph> <20001024231510.B1062@frithjof>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox