Re: Reserve one row for every distinct value in a column

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Reserve one row for every distinct value in a column
Date: 2012-05-16 07:41:42
Message-ID: CAPTjJmpANO1PJtemGpmBQW_QOVHKGPR=5QV-nMn6gMgH=U-L4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 16, 2012 at 4:53 PM, <seiliki(at)so-net(dot)net(dot)tw> wrote:
> Hi! I am trying to implement a mechanism to reserve the last row for every distinct value in column "c1".

Take a step back. Why are you needing to preserve these rows? This
smells like a likely target for normalization. Put your unique values
for c1 into a separate table, along with all data that depends only on
that, and reference it in your main table with a foreign key. Even if
you remove all the entries from your main that reference a row, the
other table will retain its data.

Chris Angelico

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Horaci Macias 2012-05-16 08:45:53 Re: vacuum, vacuum full and problems releasing disk space
Previous Message Ajit Pradnyavant 2012-05-16 06:57:05 Query regarding Intersect clause