Saludos, me podría hechar alguien una mano, xq ya estoy desesperado. Tengo 3 tablas en mi BD y quiero crear 2 foreigns keys para relaccionarlas(todo ON CASCADE)
y siempre me da error. Os spongo el error que me da con MySQLworkbech
Código:
ERROR 1005: Can't create table 'shooterbd.#sql-430_af' (errno: 150)
SQL Statement:
ALTER TABLE `shooterbd`.`juego`
ADD CONSTRAINT `foreignusuario`
FOREIGN KEY (`user` )
REFERENCES `shooterbd`.`usuario` (`nombre` )
ON DELETE CASCADE
ON UPDATE CASCADE
, ADD INDEX `foreignusuario` (`user` ASC)
ERROR: Error when running failback script. Details follow.
ERROR 1046: No database selected
SQL Statement:
CREATE TABLE `juego` (
`idJuego` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(20) NOT NULL,
`foto_disparo` varchar(45) DEFAULT NULL,
`puntuacion` int(10) unsigned NOT NULL DEFAULT '0',
`t_conexion` time NOT NULL DEFAULT '00:00:00',
`t_penalizacion` time NOT NULL DEFAULT '00:00:00',
`latitud` bigint(20) unsigned NOT NULL DEFAULT '0',
`longitud` bigint(20) unsigned NOT NULL DEFAULT '0',
`estado` tinyint(1) unsigned NOT NULL DEFAULT '0',
`muerto` tinyint(1) unsigned NOT NULL DEFAULT '0',
`destino_lat` bigint(20) unsigned NOT NULL DEFAULT '0',
`destino_lon` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`idJuego`,`user`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8
He probado:
- que la BD, tablas y campos tengan la misma codificacion UTF-8
- que los campos a relacionar sean claves primarias
-que los campos sean exactamente del mismo tipo VARCHAR(20)
-que todas las tablas sean tipo InnoDB
-que acepten los mismos values Not Null
alguien puede hecharme una mano???
por si es necesario tengo MySQL 5.5, en Windows 7 ultimate
Muchas gracias