Re: Storing an ordered list

Поиск
Список
Период
Сортировка
От Aaron Bono
Тема Re: Storing an ordered list
Дата
Msg-id bf05e51c0607281206r3f568c08v6c173232a1fbd1e8@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Storing an ordered list  ("Michael Artz" <mlartz@gmail.com>)
Список pgsql-sql
On 7/26/06, Michael Artz <mlartz@gmail.com> wrote:
On 7/26/06, Bruno Wolff III <bruno@wolff.to> wrote:
> If you use numeric instead of int, then it is easy to insert new values.

Hmm, hadn't thought about that.  How would you normally implement it?
I'm thinking that, if I wanted to insert between A and B, I could take
(A.order + B.order)/2, which would be pretty simple.  Is there a
better way?

 This is a good idea.  Then you can add a scheduled process to read through these values and turn them back to integer values on a regular basis (sort of a reindexing) to keep your numbers from becoming small enough that you start experiencing round off problems.  Perhaps you could add a trigger that says if the value entered into the order field is going out to too many decimal places, it renumbers everything. to keep the values clean.  Or better yet, add a stored procedure you call to reorder the elements that decides how to do it for you so you can easily rewrite the implementation without having to change the application.

Just some ideas...

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
==================================================================

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Chris Lukenbill"
Дата:
Сообщение: Re: return setof records
Следующее
От: "Aaron Bono"
Дата:
Сообщение: Re: primary keys as TEXT