pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Axel Straschil <axel@straschil.com>
To: pgsql-sql@postgresql.org
Subject: How to store directory like structures?
Date: Sun, 3 Apr 2005 10:13:48 +0000 (UTC)
Message-ID: <slrnd4vghu.tp.axel@m2.sine> (raw)

Hello!

I want to store some structure like:

CREATE TABLE node
(
	nodeid	SERIAL PRIMARY KEY,
	parent	INT REFERENCES node(nodeid)
			ON UPDATE CASCADE ON DELETE CASCADE,
	label	TEXT,
	UNIQUE (parent, label),
	...
	data 
	...
);

The label is used to map a node to a directory like strukture, so i can
have a function directory_for(nodeid) which gives me
/root_label/parent_label/parent_label/my_label (root labels have NULL as parent)

The problem is the ammount of queries when i've got deep nodes, and I
often have to query if a node is "in path" of another node.

Is there a good solution to build directory-tree like datastruktures?
I found, http://www.sai.msu.su/~megera/postgres/gist/ltree/ which seems
to do what i want, but I've no idea (and probalbly no chance) to get
that running on my system ;-(

Thanks,
AXEL.




view thread (12+ messages)  latest in thread

Message-ID: <slrnd4vghu.tp.axel@m2.sine>
Permalink:  ../slrnd4vghu.tp.axel@m2.sine/
Also on:    postgresql.org/message-id/slrnd4vghu.tp.axel@m2.sine

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: axel@straschil.com
  Subject: Re: How to store directory like structures?
  In-Reply-To: <slrnd4vghu.tp.axel@m2.sine>

* 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