Re: ID column naming convention

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: ID column naming convention
Date: 2015-10-19 09:25:39
Message-ID: 5624B713.4020001@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/18/15 4:32 AM, Karsten Hilbert wrote:
>> Can you tell us more about the database (ignoring nit-picking!)?
> Sure. All the clinical tables inherit from clin.clin_root_item
> which itself has a primary key (pk_item) and which, in turn,
> inherits from audit.audit_fields, which, again, has a primary
> key of its own (pk_audit). That is what makes several tables
> appear to have more than one primary key.

FWIW, I intentionally break some of my conventions when using
inheritance. For example, I normally use a single sequence to drive ALL
surrogate keys for the tables, and child tables keep the same surrogate
key as the parent (which means naming doesn't match). IMHO it makes more
sense to have inheritance do the work for you on this stuff.

BTW, if there's any interest, I have code that sets up a non-inheritance
table specifically for doing foreign keys to the inheritance parent. It
doesn't support updates right now, but should be fully safe from a FK
standpoint.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2015-10-19 09:32:38 Re: Version management for extensions
Previous Message Jim Nasby 2015-10-19 09:20:37 Re: Recommendations for migrating PG 9.3 RDS across regions