From: Aaron Bono <postgresql@aranya.com>
To: Michael Artz <mlartz@gmail.com>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-sql@postgresql.org
Subject: Re: Storing an ordered list
Date: Fri, 28 Jul 2006 14:06:21 -0500
Message-ID: <bf05e51c0607281206r3f568c08v6c173232a1fbd1e8@mail.gmail.com> (raw)
In-Reply-To: <e9c163070607261713j21d8e9a1n2e2ea25bd30de39c@mail.gmail.com>
References: <e9c163070607251958x2ef2a315w4204aa2f90e70bbe@mail.gmail.com>
<20060726203954.GA23437@wolff.to>
<e9c163070607261713j21d8e9a1n2e2ea25bd30de39c@mail.gmail.com>
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
==================================================================
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql@aranya.com, mlartz@gmail.com, bruno@wolff.to
Subject: Re: Storing an ordered list
In-Reply-To: <bf05e51c0607281206r3f568c08v6c173232a1fbd1e8@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox