Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VU2IR-0002rn-5d for pgsql-sql@arkaria.postgresql.org; Wed, 09 Oct 2013 22:31:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VU2IQ-0004Lf-Kt for pgsql-sql@arkaria.postgresql.org; Wed, 09 Oct 2013 22:31:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VU2IP-0004KS-Fs for pgsql-sql@postgresql.org; Wed, 09 Oct 2013 22:31:57 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VU2IK-00032J-O7 for pgsql-sql@postgresql.org; Wed, 09 Oct 2013 22:31:57 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VU2IH-00067C-SN for pgsql-sql@postgresql.org; Wed, 09 Oct 2013 15:31:49 -0700 Date: Wed, 9 Oct 2013 15:31:49 -0700 (PDT) From: David Johnston To: pgsql-sql@postgresql.org Message-ID: <1381357909835-5773925.post@n5.nabble.com> In-Reply-To: References: Subject: Re: Question about index/constraint definition in a table MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.8 (+) 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 JORGE MALDONADO wrote > I have a table as follows: > ------------------------------------------------ > Table Artist Colaborations > ------------------------------------------------ > * car_id (integer field, primary key) > * car_song (integer field, foreign key, foreign table is a catalog of > songs) > * car_artist (integer field, foreign key, foreign table is a catalog of > artists) > > So, I added 2 indexes to improve JOIN in queries: > 1. An index for car_song which accepts duplicates. > 2. An index for car_artist which accepts duplicates. > > Now, the combination of "car_song + car_artist" cannot be duplicated so I > think that adding a constraint on these 2 fields is the solution. > > My question: Is this the correct way to go? > > Respectfully, > Jorge Maldonado Yes. Why is it this is a question for you? Also, the car_id field becomes pointless since your new constraint is the true and natural PK. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Question-about-index-constraint-definition-in-a-table-tp5773924p5773925.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql