Re: Table with Field Serial - Problem - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Table with Field Serial - Problem
Date
Msg-id 52728DD1.5070702@gmail.com
Whole thread Raw
In response to Re: Table with Field Serial - Problem  (David Johnston <polobo@yahoo.com>)
Responses Re: Table with Field Serial - Problem
List pgsql-general
On 10/31/2013 09:32 AM, David Johnston wrote:
> Adrian Klaver-3 wrote
>>> Table1
>>>    Column  |       Type        |                          Modifiers
>>> ----------+-------------------__+-----------------------------__------------------------------__--
>>>    id   | integer           | not null default
>>> nextval('test_table_id_fld___seq'::regclass)
>>>
>>>
>>> Table2
>>> Column  |       Type        |                      related
>>> ----------+-------------------__+-----------------------------__------------------------------__--
>>>    id_table1   | integer           |  FK of Table1.id
>>>    id_lang       | integer          |  FK of lang.id
>>> <http://lang.id>
>>>    name         |  varchar
>>>
>
> The PK for table 2 is composite: the serial key from table 1 + the language
> id.  The table 1 id has to be able to repeat since the same "entity" needs
> multiple translations.  Using a serial on table 2 is also possible but a
> separate issue and probably not worth adding since you need a unique index
> on (id_table1, id_lang) regardless.
>
> The question is why isn't there some kind of identifier on table 1 that
> gives you some idea of what the id/table record is for?

Exactly the id_table1 FK has no context, it is just a number generator,
so why make it separate? If want to just generate numbers why not just
use the sequence directly?

>
> David J.
>
>



--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: Yostin Vargas
Date:
Subject: Re: Table with Field Serial - Problem
Next
From: David Johnston
Date:
Subject: Re: Explanantion on pgbouncer please