louis gonzales wrote:
> Florian,
> Are you certain:
>
> "You can only create an FK if the fields you are referencing in the
> foreign table form a PK there. And creating a PK implicitly creates an
> index, which you can't drop without dropping the PK :-("
>
Arg.. Should have written "unique index" instead of primary key..
But it doesn't change much, since a unique index and a pk are nearly
the same.
> I'm not sure I am convinced the necessity of a foreign key, "needing" to
> reference a primary keyed entry from a different table.
I tried the following:
create table a(id int4) ;
create table b(id int4, a_id int4) ;
alter table b add constraint pk foreign key (a_id) references a (id) ;
The alter table gave me an error stating that I need to have a unique index
defined on a.id...
greetings, Florian Pflug