Re: Advice on key design - Mailing list pgsql-sql

From Luca Ferrari
Subject Re: Advice on key design
Date
Msg-id CAKoxK+57gzt1zQsVXRPmswqV=r5UQPxCBoHbnEh2zzJKe=r9vQ@mail.gmail.com
Whole thread Raw
In response to Re: Advice on key design  (Bèrto ëd Sèra <berto.d.sera@gmail.com>)
Responses Re: Advice on key design
List pgsql-sql
On Wed, Jul 24, 2013 at 10:38 AM, Bèrto ëd Sèra <berto.d.sera@gmail.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



pgsql-sql by date:

Previous
From: Bèrto ëd Sèra
Date:
Subject: Re: Advice on key design
Next
From: Bèrto ëd Sèra
Date:
Subject: Re: Advice on key design