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: 2006-04-21 14:07:13
Message-ID: 4448E711.2060600@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomi NA 2006-04-21 14:20:00 Re: setting the environment locale - linux, windows
Previous Message Adam Majer 2006-04-21 14:00:17 Upgrade of Windows MSI installations (version 8.0)