Forum OpenACS Development: Re: ltree sorting

Collapse
3: Re: ltree sorting (response to 2)
Posted by Tom Jackson on
It is always a mistake to use one piece of data to serve two independent purposes. Bite the bullet and add a separate field to specify order. If it is a hierarchy, you have to be more careful in maintaining this field. I think it is perfectly okay to expose compound fields, like phone numbers, as a single field, but if you intend to select and sort by a sub-field, you need to consider the impact on performance. For instance, there is no logical difference with representing 2.1 as 1, parent 2. Then order by parent, then child as integers.

You obviously cannot achieve your goal with the above example without a separate field, which pretty much proves the point: don't mix purposes. You may also need some indication of level in a hierarchy.