Re: integrity of column used to order rows

From: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
To: cliff(at)cliffmeyers(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: integrity of column used to order rows
Date: 2003-03-19 16:50:45
Message-ID: 200303190950.45766.pgsql@bluepolka.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wednesday March 19 2003 9:18, cliff(at)cliffmeyers(dot)com wrote:
>
> What I want to be able to do is make sure that at all times the child
> records linked to a parent record have values for the "rank" field that
> are consecutive starting at 1, ie (1,2,4,5,6) not (1,2,4,5,7).
>
> Can someone offer the best suggestion to do this?

This is certainly possible via a triggered PL/pgSQL function. Of course,
whether or not it is feasible w/r/t performance or exactly how you choose
to set the ranks depends on your context. If you have appropriate indices
on the foreign key to the parent table, the overall size of the table is
probably irrelevant; use of the index would allow you to avoid traversal of
the entire table. You also have the option of writing the function in C to
get better performance.

Ed

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message jasiek 2003-03-19 18:49:27 Re: trouble with query
Previous Message Achilleus Mantzios 2003-03-19 16:38:47 Re: Listing Users