pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
help on creating table
2+ messages / 2 participants
[nested] [flat]

* help on creating table
@ 2000-10-20 10:48 pgsql-sql <pgsql-sql@fc.emc.com.ph>
  2000-10-24 21:15 ` Re: help on creating table Albert REINER <areiner@tph.tuwien.ac.at>
  0 siblings, 1 reply; 2+ messages in thread

From: pgsql-sql @ 2000-10-20 10:48 UTC (permalink / raw)
  To: pgsql-sql

Hi All,

I'm planning to have data in a tree structure when fetched.
e.g.

NODE1
   + --- NODE1_1
   + --- NODE1_2
   |        + --- NODE1_2_1
   + --- NODE1_3

Is this possible? How?

I would really appreciate any help.

Sherwin




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: help on creating table
  2000-10-20 10:48 help on creating table pgsql-sql <pgsql-sql@fc.emc.com.ph>
@ 2000-10-24 21:15 ` Albert REINER <areiner@tph.tuwien.ac.at>
  0 siblings, 0 replies; 2+ messages in thread

From: Albert REINER @ 2000-10-24 21:15 UTC (permalink / raw)
  To: pgsql-sql <pgsql-sql@fc.emc.com.ph>; 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
--------------------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-10-24 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-20 10:48 help on creating table pgsql-sql <pgsql-sql@fc.emc.com.ph>
2000-10-24 21:15 ` Albert REINER <areiner@tph.tuwien.ac.at>

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