X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id CC99E9FB27F for ; Fri, 28 Jul 2006 16:07:11 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75816-06 for ; Fri, 28 Jul 2006 16:06:55 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by postgresql.org (Postfix) with ESMTP id 037639FB280 for ; Fri, 28 Jul 2006 16:06:22 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so278323nfc for ; Fri, 28 Jul 2006 12:06:21 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=gqYQ2Z0yikSbfCbXzMlU5cJVghUHuNsouiOSBo0asve9wVuhZgV+x9X8VEPnpwJiO8rQ+BDoOa2MTg5H+BOZJzeJyh2Fg/8LdVgXgONlKL4Dcv7dVHlgF1e5O+YsCE8DxySq3M3VumonJc3DFhsrlgfy/PKYy/19KbjfHbN0WZA= Received: by 10.78.175.14 with SMTP id x14mr984541hue; Fri, 28 Jul 2006 12:06:21 -0700 (PDT) Received: by 10.78.32.10 with HTTP; Fri, 28 Jul 2006 12:06:21 -0700 (PDT) Message-ID: Date: Fri, 28 Jul 2006 14:06:21 -0500 From: "Aaron Bono" To: "Michael Artz" Subject: Re: Storing an ordered list Cc: "Bruno Wolff III" , pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_13408_5846905.1154113581107" References: <20060726203954.GA23437@wolff.to> X-Google-Sender-Auth: df090a0922a37f46 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.29 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200607/360 X-Sequence-Number: 25934 ------=_Part_13408_5846905.1154113581107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/26/06, Michael Artz wrote: > > On 7/26/06, Bruno Wolff III 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 ================================================================== ------=_Part_13408_5846905.1154113581107 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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
================================================================== ------=_Part_13408_5846905.1154113581107--