Why will this sql not create the foreign key?
DROP TABLE IF EXISTS `flow_people`;
CREATE TABLE `flow_people` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`active` enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`token` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`unixtime` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`company_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`salutation` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL,
`first_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`middle_name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`dob` date NOT NULL,
`cams` decimal(7,0) NOT NULL,
`location_id` int(8) NOT NULL,
`people_type` int(8) NOT NULL COMMENT 'flow_people_types',
`comment` longtext COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
FOREIGN KEY (`people_type`) REFERENCES flow_people_types(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1666 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
the table flow_people_types exists, it has an ID column.
I think I am missing something fundamental here, what is the problem?
Check this link MySQL Foreign Keys:
Try this: