Re: r there downsides to explicitly naming a pk column xxxx_pk

From: john snow <ofbizfanster(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: r there downsides to explicitly naming a pk column xxxx_pk
Date: 2017-12-14 20:40:50
Message-ID: CAE67tvUKuOLHPkPRVRp4XHoF9sOU8NSdGG_hzQLOn-gAKF6=Lw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

it 4am here right now sorry :-)

i'm talking about the name of the column holding the data. I mentioned the
fk constraint naming part only because we've decided on suffixing the
constraint name with an "fk", and i guess that led to his suggestion of
suffixing a table's pk column with "pk". for example: we have a table named
"units" (for units of measurement); its pk currently is named unit_id. he
wanted to name it "unit_pk".

On Fri, Dec 15, 2017 at 4:22 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Thu, Dec 14, 2017 at 1:14 PM, john snow <ofbizfanster(at)gmail(dot)com> wrote:
>
>> instead of the more conventional xxxx_id or just id?
>>
>> sorry if this may be a foolish question to some, but i'm trying to think
>> thru
>> a junior colleagues's proposal. the discussion occurred while we were
>> discussing naming our foreign key constraints using the convention
>> "childtable_parenttable_colname_fk".
>>
>
> ​Are you talking about the constraint name or the name of the column
> holding the data?​
>
> ​Identifiers in PostgreSQL can only be 64 characters (bytes?) long.
>
> If it is the column name I wouldn't get too crazy or people writing out
> SQL joins manually will be asking you to pay their medical bills...
>
> I generally avoid naming any column "id" - tables get short code aliases
> and those prefix the "id". I then name the column in the FK the exact same
> name. I rely on system defaults for choosing the names of the
> corresponding constraints and indexes.
>
> David J.
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Gavin Flower 2017-12-14 20:41:08 Re: r there downsides to explicitly naming a pk column xxxx_pk
Previous Message David G. Johnston 2017-12-14 20:22:41 Re: r there downsides to explicitly naming a pk column xxxx_pk