From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
Cc: | john snow <ofbizfanster(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: r there downsides to explicitly naming a pk column xxxx_pk |
Date: | 2017-12-14 20:48:56 |
Message-ID: | CAKFQuwbiZgU527QMKB0GgdfaVLmpN39RkPUzsgw-dd7gFS2f8Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Thu, Dec 14, 2017 at 1:41 PM, Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz
> wrote:
> Since we know the current table name, it is redundant to name the table's
> primary key with the its table name.
>
Redundant but useful - I am a huge proponent of USING clauses in joins:
pk_tbl JOIN fk_tbl USING (pk_tbl_id)
As for "finding the PK" - its almost always the first column in the table,
ends in "id", and has a reasonable prefix.
Being able to "grep pk_tbl_id" is also nice in many cases. Grepping "id"
provides no useful value - though if one always uses table prefixes then
grepping "pk_tbl.id" would mitigate that particular problem.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Robson | 2017-12-14 20:58:48 | Re: r there downsides to explicitly naming a pk column xxxx_pk |
Previous Message | Gavin Flower | 2017-12-14 20:41:08 | Re: r there downsides to explicitly naming a pk column xxxx_pk |