Re: Advice on key design

From: Luca Ferrari <fluca1978(at)infinito(dot)it>
To: Bèrto ëd Sèra <berto(dot)d(dot)sera(at)gmail(dot)com>
Cc: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Advice on key design
Date: 2013-07-24 09:39:42
Message-ID: CAKoxK+57gzt1zQsVXRPmswqV=r5UQPxCBoHbnEh2zzJKe=r9vQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Jul 24, 2013 at 10:38 AM, Bèrto ëd Sèra <berto(dot)d(dot)sera(at)gmail(dot)com> wrote:

> What would be the rationale behind the serial number?
>

The serial key, also named "surrogate key" is there for management
purposes. Imagine one day you find out your database design is wrong
and what was unique the day before is no more so, how can you find
your records?
The idea is to have a surrogate key to save you from real world
troubles, and then constraints to implement the database design.

I usually use this convention:
- primary surrogate keys named pk and defined as primary keys
- database design keys named _key and defined with a unique constraint.

Luca

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bèrto ëd Sèra 2013-07-24 09:47:44 Re: Advice on key design
Previous Message Bèrto ëd Sèra 2013-07-24 08:38:29 Re: Advice on key design