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 E66C253352 for ; Sun, 3 Apr 2005 19:09:55 +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 19586-10 for ; Sun, 3 Apr 2005 18:09:46 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 8178353345 for ; Sun, 3 Apr 2005 19:09:44 +0100 (BST) Received: (qmail 11156 invoked from network); 3 Apr 2005 20:10:02 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 3 Apr 2005 20:10:02 +0200 To: "Axel Straschil" , pgsql-sql@postgresql.org Subject: Re: How to store directory like structures? References: Message-ID: From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Sun, 03 Apr 2005 20:09:43 +0200 In-Reply-To: User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/28 X-Sequence-Number: 20921 Use the ltree datatype ! It's made specifically for this purpose. http://www.sai.msu.su/~megera/postgres/gist/ On Sun, 03 Apr 2005 12:13:48 +0200, 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 ;-( > > 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 >