pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anton Gavazuk <antongavazuk@gmail.com>
To: JORGE MALDONADO <jorgemal1960@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Advice on key design
Date: Wed, 24 Jul 2013 00:02:43 +0200
Message-ID: <3311319936507639588@unknownmsgid> (raw)
In-Reply-To: <CAAY=A7_ZKoCRjP19oLRYfQeV1=Q=c-3cX+qDmPfZC8_o_B8msQ@mail.gmail.com>
References: <CAAY=A7_ZKoCRjP19oLRYfQeV1=Q=c-3cX+qDmPfZC8_o_B8msQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Hi Jorge,

In your case it would be lpp_id as PK, and
lpp_person_id,lpp_language_id as unique constraint

Thanks,
Anton

On Jul 23, 2013, at 23:45, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:

> I have 2 tables, a parent (tbl_persons) and a child (tbl_languages_per_person) as follows (a language table is also involved):
>
> ------------------
> tbl_persons
> ------------------
> * per_id
> * per_name
> * per_address
>
> --------------------------------------
> tbl_languages_per_person
> --------------------------------------
> * lpp_person_id
> * lpp_language_id
> * lpp_id
>
> As you can see, there is an obvious key in the child table which is "lpp_person_id + lpp_language_id", but I also need the field "lpp_id" as a unique key which is a field that contains a consecutive number of type serial.
>
> My question is: what should I configure as the primary key, "lpp_person_id + lpp_language_id" or "lpp_id"?
> Is the role of a primary key different from that of a unique index?
>
> With respect,
> Jorge Maldonado
>
>
>
>
>
>


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (10+ messages)  latest in thread

Message-ID: <3311319936507639588@unknownmsgid>
Permalink:  ../3311319936507639588@unknownmsgid/
Also on:    postgresql.org/message-id/3311319936507639588@unknownmsgid

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: antongavazuk@gmail.com, jorgemal1960@gmail.com
  Subject: Re: Advice on key design
  In-Reply-To: <3311319936507639588@unknownmsgid>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox