I am unable to define a foreign key with the following three tables.  I am 
unable to find the error having searched the documentation and tried several 
variations.  

Note that I created the first two tables with and without the index clause in 
the table ddl with no difference in outcome.

The three tables and the first foreign key, person_person_address_FK1, create 
properly.  The second foreign key, address_person_address_FK1, causes the error.

Please help.

create table person (
   person_id int unsigned not null auto_increment,
   constraint person_pk primary key (person_id),
   index(person_id));

create table address (
   address_id int unsigned not null auto_increment,
   constraint address_pk primary key (address_id),
   index(address_id));

create table person_address (
   person_id int unsigned not null,
   address_id int unsigned not null);

-- This statement works.
alter table person_address
 add constraint person_person_address_FK1 
foreign key (person_id) references person (person_id); 

-- This statement fails.
alter table person_address
 add constraint address_person_address_FK1 
foreign key (address_id) references address (address_id); 

Replies may be sent to [EMAIL PROTECTED]

Thank you!

Steve

Reply via email to