List:General Discussion« Previous MessageNext Message »
From:Olusola Fadero Date:March 24 2006 6:00pm
Subject:Re: Foreign keys
View as plain text  
I had that problem as well and a quick search revealed this:

A) Whole databases are not handled by InnoDB. The individual tables are.
Check the results of "SHOW CREATE TABLE table_name_here" for each table
you are linking from and linking to. You should see ENGINE = InnoDB after
the last ) but before the final ; in each definition. If not, you need to
change your tables to use that engine.

B) Each column participating in either end of a FOREIGN KEY must be of the
same data type and size and signedness (everything about the columns must
match except the names and comments)

C) Each column participating in either end of a FOREIGN KEY must be the
leftmost column of an index. Simply declaring a FOREIGN KEY constraint
will not automatically create an index on the child table if one is
missing.

D) When all else fails, read the detailed error message returned by InnoDB
by using the SHOW INNODB STATUS; command

Basically ensure that your foriegn key is an index  in the group_system
table.

Regards,
Olusola


On 24/03/06, João Cândido de Souza Neto <joao@stripped> wrote:
>
> Hello everybody.
>
> I'm using php 4.4 and mysql 5.0 and i'm having the bellow issue:
>
> I've a group table and a system table, bellow this i have a group_system
> table that has a foreign key to group table and to system table. When a
> tried to delete one register in the group_system table, it gives me the
> bellow error:
>
> Cannot add or update a child row: a foreign key constraint fails
> (`buffets/group_system`, CONSTRAINT `fk_group_group_sistema` FOREIGN KEY
> (`idgrp`) REFERENCES `group` (`idgrp`) ON DELETE CASCADE ON
>
> Anyone knows to tell me wath's happening here?
>
> Thanks for all tips.
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1
>
>

Thread
Foreign keysJoão Cândido de Souza Neto24 Mar
  • Re: Foreign keysOlusola Fadero24 Mar
    • Stored procedures and viewsChris Carrier24 Mar
      • Re: Stored procedures and viewsMartijn Tonies24 Mar
        • RE: Stored procedures and viewsChris Carrier24 Mar
          • Re: Stored procedures and viewsMartijn Tonies24 Mar
            • RE: Stored procedures and viewsGordon24 Mar