Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V1kfS-0003zD-69 for pgsql-sql@arkaria.postgresql.org; Tue, 23 Jul 2013 22:02:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V1kfR-0005vA-LO for pgsql-sql@arkaria.postgresql.org; Tue, 23 Jul 2013 22:02:49 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V1kfQ-0005uu-Fx for pgsql-sql@postgresql.org; Tue, 23 Jul 2013 22:02:48 +0000 Received: from mail-vc0-x22c.google.com ([2607:f8b0:400c:c03::22c]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V1kfN-0002Y0-C7 for pgsql-sql@postgresql.org; Tue, 23 Jul 2013 22:02:47 +0000 Received: by mail-vc0-f172.google.com with SMTP id m17so4466921vca.31 for ; Tue, 23 Jul 2013 15:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type; bh=/NvzzHC248OfZ2Vba0U/OKblJ420gzpdc9aeqBMzurk=; b=u2kO2DC9AP30D6NPOITRWjBc2N6Pn0MMO9k3xy2eSwNLbqmfQAUISv1itq/ZsE4D3B 5jYlWpt1Put7OM5qoh8cOAYc7m1dv1vVmtHd7G1HwK++adghWocsaO00bnZAZCVPhs2b QnJSCswYOzGLe3f7YnWF3RKSRm26v0lxrc+NN9BRWXK2TfUYFnIRV4UUpiCRL0J2pPx4 PjQNlR60uQRjTm8mafO5DIFjT71oG1N+Al+CQm0u0pKPfvRAukrwVoH7+CR9n3j0a39k 6Ivj33NerP4XkPyBXn09U1HWyr/4uL58GJa0ZS7lzspwr7HfkLdLLXxfal8/mLfTQ4Lb Db7A== X-Received: by 10.220.43.210 with SMTP id x18mr12597009vce.96.1374616963409; Tue, 23 Jul 2013 15:02:43 -0700 (PDT) References: From: Anton Gavazuk In-Reply-To: Mime-Version: 1.0 (1.0) Date: Wed, 24 Jul 2013 00:02:43 +0200 Message-ID: <3311319936507639588@unknownmsgid> Subject: Re: Advice on key design To: JORGE MALDONADO Cc: "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=ISO-8859-1 X-Pg-Spam-Score: 0.7 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 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