> Is it ALLWAYS the case, that a FK constraint refers to the PK
> of another table? Or could arbitraty attributes of another
> table be referenced by a FK too?
arbitrary (usually unique indexed) columns
> Is it guaranteed that I find the PK definition of a table
> allways in the index <tablename>_pkey?
No. I think there is a column in pg_index that marks a pk already.
(for odbc) This would imho be the best way.
> Another (my preferred) way would be to name the automatically
> created PK index something like "pg_pkey_<tableoid>". This
You want to have the ability to:
1. create table
2. create unique index
3. alter table add constraint primary key (uses existing index)
The automatic naming should be irrelevant.
Andreas