Question about index/constraint definition in a table

From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Question about index/constraint definition in a table
Date: 2013-10-09 22:23:39
Message-ID: CAAY=A7_b6xhUN3CwUJw+5+5K60dcnV0buRHHRz2Vsmx_jcz6aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2013-10-09 22:31:49 Re: Question about index/constraint definition in a table
Previous Message Craig R. Skinner 2013-10-08 17:04:15 Many to many link tables with history?