Re: A few questions about ltree - Mailing list pgsql-general

From Teodor Sigaev
Subject Re: A few questions about ltree
Date
Msg-id 4448E711.2060600@sigaev.ru
Whole thread Raw
In response to A few questions about ltree  (Alban Hertroys <alban@magproductions.nl>)
Responses Re: A few questions about ltree
List 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@sigaev.ru
                                                    WWW: http://www.sigaev.ru/

pgsql-general by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: GiST index slower than seqscan
Next
From: "Tomi NA"
Date:
Subject: Re: setting the environment locale - linux, windows