X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CD04753ADE for ; Sun, 3 Apr 2005 18:00:19 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08435-04 for ; Sun, 3 Apr 2005 17:00:09 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id 372F953AB7 for ; Sun, 3 Apr 2005 18:00:07 +0100 (BST) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.13.4/8.13.4) with ESMTP id j33H051F007733; Sun, 3 Apr 2005 21:00:05 +0400 (MSD) Date: Sun, 3 Apr 2005 21:00:05 +0400 (MSD) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: Axel Straschil Cc: pgsql-sql@postgresql.org Subject: Re: How to store directory like structures? In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.336 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200504/26 X-Sequence-Number: 20919 On Sun, 3 Apr 2005, Axel Straschil wrote: > 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 ;-( what's a problem with ltree ? > > Thanks, > AXEL. > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83