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

Поиск
Список
Период
Сортировка
От Gavin Flower
Тема Re: r there downsides to explicitly naming a pk column xxxx_pk
Дата
Msg-id 36ba1f3f-3b37-0993-7935-597904ff13eb@archidevsys.co.nz
обсуждение исходный текст
Ответ на Re: r there downsides to explicitly naming a pk column xxxx_pk  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: r there downsides to explicitly naming a pk column xxxx_pk  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: r there downsides to explicitly naming a pk column xxxx_pk  (Greg Robson <gregrobson@gmail.com>)
Список pgsql-novice
On 12/15/2017 09:22 AM, David G. Johnston wrote:
> On Thu, Dec 14, 2017 at 1:14 PM, john snow <ofbizfanster@gmail.com 
> <mailto:ofbizfanster@gmail.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.
>
I use 'id' for the primary key of the current table, and 'xxx-id' for a 
foreign key.

So it is easy to identify the primary key, and to spot the foreign keys.

Since we know the current table name, it is redundant to name the 
table's primary key with the its table name.


Cheers,
Gavin



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

Предыдущее
От: john snow
Дата:
Сообщение: 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