From: | "Aaron Bono" <postgresql(at)aranya(dot)com> |
---|---|
To: | "Michael Artz" <mlartz(at)gmail(dot)com> |
Cc: | "Bruno Wolff III" <bruno(at)wolff(dot)to>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Storing an ordered list |
Date: | 2006-07-28 19:06:21 |
Message-ID: | bf05e51c0607281206r3f568c08v6c173232a1fbd1e8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 7/26/06, Michael Artz <mlartz(at)gmail(dot)com> wrote:
>
> On 7/26/06, Bruno Wolff III <bruno(at)wolff(dot)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
==================================================================
From | Date | Subject | |
---|---|---|---|
Next Message | Aaron Bono | 2006-07-28 19:28:14 | Re: primary keys as TEXT |
Previous Message | Chris Lukenbill | 2006-07-28 18:01:30 | Re: return setof records |