Dear Steve!
You must set the column address_id as primary key in the table person_address. That should solve your problem. Generally table, you want to join with foreign key, should have primary key. The primary key should include the column that you use for the foreign key. Also, you should have an index on the table including this column. This column should be the first in the index. If the primary key is equal with this column, you must not create an index. Hope this will help you. Regards Bela, Kocsis -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, December 05, 2004 2:42 PM To: [EMAIL PROTECTED] Subject: Foreign Key Error 1005:150 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 --------------------------------------------------------------------------------------------------- Ez az elektronikus Ãzenet Ãs minden csatolt file bizalmas informÃciÃt tartalmaz, kizÃrÃlag a cÃmzett/ek rÃszÃre, Ãgy ha valamilyen hiba folytÃn tÃves helyre Ãrkezne meg, kÃrjÃk tÃrÃlje az Ãzenetet. Ilyen esetben nem jogosult az elektronikus Ãzenetet Ãs a csatolt file-okat bÃrmilyen mÃdon felhasznÃlni, nem teheti kÃzzà Ãs nem mÃsolhatjak le azokat. Valamennyi elektronikus Ãzenet, amelyet a dm Kft-hez, vagy annak munkavÃllalÃjÃhoz cÃmeztek, vagy onnan kÃldtek, Ãzleti jellegÅnek tekintendÅ. Ennek megfelelÅen az Ãzenet kÃldÅje vagy cÃmzettje hozzÃjÃrul ahhoz, hogy az dm Kft. mÃsik, az eredeti cÃmzettÅl vagy kÃldÅtÅl eltÃrÅ vezetÅje vagy alkalmazottja Ãltal az Ãzenet megismerhetÅ legyen annak ÃrdekÃben, hogy a dm Kft. tevÃkenysÃgÃnek folyamatossÃga Ãs felÃgyelete biztosÃthatà legyen. A dm Kft. nem vÃllal felelÅssÃget az informÃciÃk hibÃtlan Ãs teljes kÃzvetÃtÃsÃÃrt, illetve az elektronikus Ãzenet vÃrusmentessÃgÃÃrt. Azon elektronikus Ãzenetek tartalma, amelyek nem vonatkoznak a dm Kft. Ãzleti mÅkÃdÃsÃre, a dm Kft. hivatalos mÅkÃdÃse kÃrÃben sem kiadÃsra sem jÃvÃhagyÃsra nem kerÃltek. --------------------------------------------------------------------------------------------------- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]