Re: Table with Field Serial - Problem

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Yostin Vargas <yostinv(at)gmail(dot)com>
Cc: David Johnston <polobo(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Table with Field Serial - Problem
Date: 2013-10-31 18:22:29
Message-ID: 52729FE5.5080501@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/31/2013 11:12 AM, Yostin Vargas wrote:
> i really dont need a number generator, only a unique PK. but i want that
> this PK be generate automatically
>
> for example i have a Category calling Computer in English but i have the
> same Category in Spanish (Computadora) i assigned the ID->1 for both

So table1 is the category table:

id serial
category varchar

or

Why not just make your PK a natural one (category, language)?

In the end whatever works for you, works. I am just asking because I
could not follow the logic and I needed guidance.

>
> So if i put the Pk ID in the table2 number i have error for unique
> violation when i want INSERT another name in a diferent language for
> the same category
>
> For that reason i declare ID in the table2 like a FK from ID in the table1
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gary Fu 2013-10-31 18:51:42 autovaccum task got cancelled
Previous Message Yostin Vargas 2013-10-31 18:12:13 Re: Table with Field Serial - Problem