Re: Table and Field namestyle best practices?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: novnov <novnovice(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Table and Field namestyle best practices?
Date: 2006-11-08 19:12:16
Message-ID: b42b73150611081112k343481d8w40911f73e0c15cce@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/8/06, novnov <novnovice(at)gmail(dot)com> wrote:
>
> I'm new to pgsql, mostly coming from MSSQL. It sounds like it's simplest to
> keep field names lowercase with pgsql, so I will have to change some habits
> I've developed over the years. I would like to glean whatever collective
> wisdom I can here from experienced pgsql devs.
>
> I've been using namestyles with mixed case like OrgID. That is much more
> readable than orgid. Probably a good convention to adopt would be to use
> namestyles like org_id. That change I can live with.

of course, it's all in the eye of the beholder, but i think org_id
looks much better than OrgID. I suggest not prefixing tables with
'tbl', but idx_ for indexes and fk_ for foreign keys is ok. I also
think its ok to do on_xyx_delete for a delete trigger on table xyz.

some people like to name id columns 'id' and refer to that column as
xyz_id for foreign key reference, but I prefer to write out xyz_id in
all tables...it helps with natural joins and searching. this is
basically your argument as well.

also, and this is getting into flamewar territory, but i prefer to not
pluralize tables (create table order) for conceptual reasons. no big
deal though really.

my tables do not automatically get an 'id' column although they often
do...this is barely on topic for your post so ill leave it there ;-)

one last thing (also not really on topic), and this is very much
against the grain, but I do not do upper/lower case mixture that I see
in 95% of the sql on the web:

SELECT * FROM order WHERE

it reminds me too much of cobol, er COBOL and it makes my brain hurt.
i also passively agressively affirm my minority stand on this issue by
deliberately having lousy capitalization on the various lists.

regards,
merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shoaib Mir 2006-11-08 19:30:03 Re: 8.1.2 postmaster died
Previous Message Talha Khan 2006-11-08 19:09:36 Re: 8.1.2 postmaster died