Re: [GENERAL] Tree structure

2013-10-10 Thread Kaare Rasmussen
Hi Rémi Hey sorry if my answer is stupid, but there is an extension for array, even if it is limited to int (but int could be indexes of row) It's named http://www.postgresql.org/docs/9.3/static/intarray.html It provides essential function, although lacking some (I re-implemented union of arra

Re: [GENERAL] Tree structure

2013-10-10 Thread Rémi Cura
Hey sorry if my answer is stupid, but there is an extension for array, even if it is limited to int (but int could be indexes of row) It's named http://www.postgresql.org/docs/9.3/static/intarray.html It provides essential function, although lacking some (I re-implemented union of array with disjoi

Re: [GENERAL] Tree structure

2013-10-10 Thread Kaare Rasmussen
Hi Merlin On Thu, Oct 10, 2013 at 1:00 AM, Kaare Rasmussen wrote: I'm quite surprised there seem to be no way in core to treat an array as an array. Using @> treats it as a set, AFAICT. can you elaborate on that? merlin To me, an array is a vector (or a vector of vectors). So I'm looking f

Re: [GENERAL] Tree structure

2013-10-10 Thread Merlin Moncure
On Thu, Oct 10, 2013 at 1:00 AM, Kaare Rasmussen wrote: > Sorry, got tangled up in this thing called 'real life'. > > >> If I understand you correctly, you want a prefix match, and sure there's >> a PostgreSQL extension for that: > > > OK, that seems to do the job, thanks a lot. The only small qui

Re: [GENERAL] Tree structure

2013-10-09 Thread Kaare Rasmussen
Sorry, got tangled up in this thing called 'real life'. If I understand you correctly, you want a prefix match, and sure there's a PostgreSQL extension for that: OK, that seems to do the job, thanks a lot. The only small quibble is that it's an extension. I'm quite surprised there seem to b

Re: [GENERAL] Tree structure

2013-09-23 Thread Merlin Moncure
On Fri, Sep 20, 2013 at 6:29 AM, Kaare Rasmussen wrote: > Hi > > I'm trying to determine the best way to represent a simple tree structure > (like a file/dir tree or a uri path). I guess that's done a zillion times > before; I just don't seem to be able to find the right solution. I have one > spe

Re: [GENERAL] Tree structure

2013-09-23 Thread Chris Travers
On Sun, Sep 22, 2013 at 9:48 PM, Kaare Rasmussen wrote: > Hi Alban > > > 4. Using a recursive common table expression (CTE). >> http://www.postgresql.org/**docs/9.2/static/queries-with.**html >> > > Yes, you're right. In fact that's wh

Re: [GENERAL] Tree structure

2013-09-23 Thread Rémi Cura
BE carefull you have a number of limitation with recursive cte (I'm thinking of update and so.) You can work around with plpgsql but it might be painfull. You forgot a solution : if you need powerfull graph features, use postgres as a database and a SPARQL speaking frontend. It may be a bit of ove

Re: [GENERAL] Tree structure

2013-09-22 Thread Kaare Rasmussen
Hi Alban 4. Using a recursive common table expression (CTE). http://www.postgresql.org/docs/9.2/static/queries-with.html Yes, you're right. In fact that's what I'm testing a way to replace, as I'm not confident in the performance in all situations. My fault entirely; I should have told so f

Re: [GENERAL] Tree structure

2013-09-20 Thread hari . fuchs
Kaare Rasmussen writes: > Hi > > I'm trying to determine the best way to represent a simple tree > structure (like a file/dir tree or a uri path). I guess that's done a > zillion times before; I just don't seem to be able to find the right > solution. I have one special request, that I'd like to

Re: [GENERAL] Tree structure

2013-09-20 Thread Alban Hertroys
> 1. As strings > There's no dedicated function (@>) > WHERE clause should read something like 'a/b/c/d' LIKE column || '%', > which is both ugly and (I guess) non indexable > Perhaps regex indexes would work, but not efficient and not optimal > > 2. As array of strings > My favorite, would

Re: [GENERAL] Tree structure

1999-02-26 Thread K.T.
Its been a while since I wrote this and its kinda fuzzy at this hour, but this will give you a general direction to go and you can work out the specifics... If you know the depth of the tree then you can create a field of a specified length and store something like: tree_field varchar(16) A AA AB

Re: [GENERAL] Tree structure

1999-02-26 Thread Peter T Mount
On Fri, 26 Feb 1999, Kaare Rasmussen wrote: > I can't figure this one out. I need a tree structure like this > > Number Pointer > 10 > 21 > 31 > 42 > 50 > 61 > 75 > > This should somehow show up like this > Num

RE: [GENERAL] Tree structure

1999-02-26 Thread Michael Davis
You could try select spaces(pointer::int4) || Number; Where spaces() is a function that inserts "pointer" number of spaces (or dashes if you want to create your own function). Not sure if spaces() exists in Postgres or not, but it seems I read about it or a similar function somewhere.