Django uses the following syntax to define foreign keys under MySQL/InnoDB:
CREATE TABLE `system_script_queue` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`execution_time` datetime NOT NULL,
`period` integer NOT NULL,
`system_script_id` integer NOT NULL REFERENCES `system_script` (`id`)
);
Using that syntax, maybe 1/3 of my foreign key constraints are being ignored by the DB.
If I'm reading this tech note correctly (http://dev.mysql.com/doc/refman/5.0/en/example-foreign-keys.html), that's the wrong syntax to use. The correct syntax is this one:
CREATE TABLE `system_script_queue` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`system_script_id` integer NOT NULL,
`execution_time` datetime NOT NULL,
`period` integer NOT NULL,
foreign key (`system_script_id`) references `system_script` (`id`)
);
Using this syntax, all of my foreign key constraints seem to be successfully created.