Re: help on creating table - Mailing list pgsql-sql

From Albert REINER
Subject Re: help on creating table
Date
Msg-id 20001024231510.B1062@frithjof
Whole thread Raw
In response to help on creating table  ("pgsql-sql" <pgsql-sql@fc.emc.com.ph>)
List pgsql-sql
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
--------------------------------------------------------------------------


pgsql-sql by date:

Previous
From: Tomas Berndtsson
Date:
Subject: Re: knowing which columns have beend UPDATEd inside a TRIGGER?
Next
From: Jie Liang
Date:
Subject: How to call a shell command in rule