Advice on index and constraint definition - Mailing list pgsql-novice

From JORGE MALDONADO
Subject Advice on index and constraint definition
Date
Msg-id CAAY=A78ebKGyd_CB+d2GqW4=FRSo1fSeYBRDtjNRC+oPxY6nKA@mail.gmail.com
Whole thread Raw
Responses Re: Advice on index and constraint definition  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-novice
Hi,

I have a table like the one below where all of the fields are foreign keys except "prv_id" which is the primary key:

prv_id                      serial
prv_user_id             inetger
prv_client_id            integer
prv_customs_id       integer
prv_patent_id          integer
prv_doctype_id        integer


a) I read that it is a good idea to add an index for every foreign key in order to improve record management when selecting data for example.

b) I need to avoid duplicates in the combination of fields "prv_user_id, prv_client_id, prv_customs_id, prv_patent_id, prv_doctype_id" so this drives me to set a constraint with such a field combination.

Are statements (a) and (b) correct?

Respectfully,
Jorge Maldonado

pgsql-novice by date:

Previous
From: David G Johnston
Date:
Subject: Re: Unable to connect remotely to postgres db server
Next
From: David G Johnston
Date:
Subject: Re: Advice on index and constraint definition