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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: r there downsides to explicitly naming a pk column xxxx_pk
Дата
Msg-id CAKFQuwbiZgU527QMKB0GgdfaVLmpN39RkPUzsgw-dd7gFS2f8Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: r there downsides to explicitly naming a pk column xxxx_pk  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Список pgsql-novice
On Thu, Dec 14, 2017 at 1:41 PM, Gavin Flower <GavinFlower@archidevsys.co.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.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Gavin Flower
Дата:
Сообщение: Re: r there downsides to explicitly naming a pk column xxxx_pk
Следующее
От: Greg Robson
Дата:
Сообщение: Re: r there downsides to explicitly naming a pk column xxxx_pk