i use mysql work bench to export sql from erd that i create, but when i try to importing it to mysql, i just get error 150 Cannot create table.
when i try to remove constrain of service child, its just work. but i need to keep those referenced.
and every table that reference to service table, also have this error too. where am i wrong ?
CREATE TABLE IF NOT EXISTS `service` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
`seq` INT(11) NOT NULL ,
`image` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;
CREATE TABLE IF NOT EXISTS `service_package` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`sc_id` INT(11) NOT NULL ,
`lang` INT(11) NOT NULL ,
`package` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `service_package_id` (`sc_id` ASC) ,
CONSTRAINT `service_package_id`
FOREIGN KEY (`sc_id` )
REFERENCES `service` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;
You’re using
ENGINE = MyISAMon the service table. Try usingENGINE = InnoDBinstead (as you do on theservice_packagetable).Foreign keys do not work with the MyIsam storage engine.