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 3DF7753330 for ; Sun, 3 Apr 2005 13:02:00 +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 36802-10 for ; Sun, 3 Apr 2005 12:01:57 +0000 (GMT) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id AAD275333B for ; Sun, 3 Apr 2005 13:01:56 +0100 (BST) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1DI3lu-0002AS-Gu for pgsql-sql@postgresql.org; Sun, 03 Apr 2005 14:00:06 +0200 Received: from v216-233.vps.tuwien.ac.at ([128.131.216.233]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2005 14:00:06 +0200 Received: from axel by v216-233.vps.tuwien.ac.at with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2005 14:00:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Axel Straschil Subject: How to store directory like structures? Date: Sun, 3 Apr 2005 10:13:48 +0000 (UTC) Lines: 30 Message-ID: X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: v216-233.vps.tuwien.ac.at User-Agent: slrn/0.9.8.1 (Linux) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/23 X-Sequence-Number: 20916 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.