Search Postgresql Archives

Re: A few questions about ltree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
                                                   WWW: http://www.sigaev.ru/


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux