Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: A few questions about ltree


  • From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
  • To: Alban Hertroys <alban(at)magproductions(dot)nl>
  • Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
  • Subject: Re: A few questions about ltree
  • Date: Fri, 21 Apr 2006 18:07:13 +0400
  • Message-id: <4448E711(dot)2060600(at)sigaev(dot)ru>

That's the "classical" way, which is also used in our current implementation with integers instead of ltrees, but it's not very easy to query efficiently (at least ordering seems to remain a problem).

That (with integer ids) is classic way to support graph structure, ltree was develop specially for trees.


Maybe something along the lines of the following is possible?:
Exact, it's for what ltree was developed.

Do ltrees know that a node with path 'A.B.D' references it's parent 'A.B'? I mean, can ltree 'A.B' equal ltree 'A.B.D' somehow while the strings are unequal? Can it be made to know that somehow (functional foreign keys or something - maybe using "ltree_isparent(ltree, ltree)")?

Yes, use ltree_isparent or

contrib_regression=# select 'a.b.c' <@ 'a.b'::ltree;
 ?column?
----------
 t
(1 row)

contrib_regression=# select 'a.b.c.d' <@ 'a.b'::ltree;
 ?column?
----------
 t
(1 row)
contrib_regression=# select 'a.b.c.d'::ltree ~ 'a.b.*{1}';
 ?column?
----------
 f
(1 row)

contrib_regression=# select 'a.b.c'::ltree ~ 'a.b.*{1}';
 ?column?
----------
 t
(1 row)



I can determine things like this with a few experiments, but I want to know "the right way" to work with ltrees and referential integrity. How do people use this?

That's right way.

--
Teodor Sigaev                                   E-mail: teodor(at)sigaev(dot)ru
                                                   WWW: http://www.sigaev.ru/



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group