pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: What are the (various) best practices/opinions for table/column/constraint naming?
Date: Sat, 09 Feb 2008 11:58:35 +0100
Message-ID: <20080209105835.240720@gmx.net> (raw)
In-Reply-To: <47ACC3E5.2060207@kensystem.com>
References: <47ACC3E5.2060207@kensystem.com>


Speaking on behalf of the GNUmed schema.

The type of thing comes first for consistency.

primary key: pk

   Some might argue pk_<table_name> is preferrable such that
   in joins one ist not forced to use column aliases. We do
   in such cases. The "... where table.pk = ..." just seems
   soo intuitive.

foreign key: fk_<foreign_table_name>

   This then affords fk_<foreign_table_name>_<foreign_table_column>
   should that ever be needed (likely an indication of bad design).

indices: idx_<table>_<column>

sequences: so far we relied on PG giving us a name

constraints: named by what they *do*, such as ensure_..._consistency

functions: f_<purpose>

trigger functions: trf_<purpose>

trigger: tr_<purpose>

> And other naming conventions suggest using mixed/camel case 
> (quoted-identifiers)
We don't use mixed case as that would *require* quoting which is
liable to being forgotten.

Not much help, just our convention.

Karsten
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer



view thread (2+ messages)

Message-ID: <20080209105835.240720@gmx.net>
Permalink:  ../20080209105835.240720@gmx.net/
Also on:    postgresql.org/message-id/20080209105835.240720@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Karsten.Hilbert@gmx.net
  Subject: Re: What are the (various) best practices/opinions for table/column/constraint naming?
  In-Reply-To: <20080209105835.240720@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox