agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: David Johnston <polobo@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: Question about index/constraint definition in a table
Date: Wed, 9 Oct 2013 15:31:49 -0700 (PDT)
Message-ID: <1381357909835-5773925.post@n5.nabble.com> (raw)
In-Reply-To: <CAAY=A7_b6xhUN3CwUJw+5+5K60dcnV0buRHHRz2Vsmx_jcz6aw@mail.gmail.com>
References: <CAAY=A7_b6xhUN3CwUJw+5+5K60dcnV0buRHHRz2Vsmx_jcz6aw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
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-tp5773...
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
view thread (3+ messages) latest in thread
Message-ID: <1381357909835-5773925.post@n5.nabble.com>
Permalink: ../1381357909835-5773925.post@n5.nabble.com/
Also on: postgresql.org/message-id/1381357909835-5773925.post@n5.nabble.com
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: polobo@yahoo.com
Subject: Re: Question about index/constraint definition in a table
In-Reply-To: <1381357909835-5773925.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox