-2
hi my code is giving error #1005 - Can not create table foo
.aula
(error no. 150 "Foreign key Constraint is incorrectly Formed"
DROP TABLE IF EXISTS `aula`;
CREATE TABLE IF NOT EXISTS `aula` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`turma_id` int(11) NOT NULL,
`professor_id` int(11) NOT NULL,
`aluno_id` int(11) NOT NULL,
`valor` float NOT NULL,
`data` varchar(45) NOT NULL,
`horarioInicio` varchar(45) NOT NULL,
`horarioTermino` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_aula_aluno_idx` (`aluno_id`),
KEY `fk_aula_professor_idx` (`professor_id`),
KEY `fk_aula_turma_idx` (`turma_id`),
CONSTRAINT `fk_aula_aluno` FOREIGN KEY (`aluno_id`) REFERENCES `aluno` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_aula_professor` FOREIGN KEY (`professor_id`) REFERENCES `professor` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_aula_turma` FOREIGN KEY (`turma_id`) REFERENCES `turma` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
Publish the structure of all tables involved, which Database and version.
– Motta