Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/03/2009, 14:25
MigueCadiz
 
Fecha de Ingreso: agosto-2004
Mensajes: 85
Antigüedad: 19 años, 8 meses
Puntos: 0
Fallo de novato

Tengo esta sentencia SQL para crear las tablas de una BD en NetBeans.
Cuando la ejecuto me salen estos errores:

Código de error 1005, estado SQLHY000: Can't create table 'tienda.clientes' (errno: 150)
Línea 28, columna 1

Código de error 1005, estado SQLHY000: Can't create table 'tienda.productos' (errno: 150)
Línea 44, columna 1


La sentencia es:




USE `Tienda`;

-- -----------------------------------------------------
-- Table `Tienda`.`Ventas`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Tienda`.`Ventas` (
`idVenta` INT NOT NULL ,
`idProducto` INT NOT NULL ,
`PasswordCliente` VARCHAR(25) NOT NULL ,
`Unidades` INT NOT NULL ,
`CantidadTotal` INT NOT NULL ,
`FechaVenta` DATETIME NULL ,
PRIMARY KEY (`idVenta`, `idProducto`) );


-- -----------------------------------------------------
-- Table `Tienda`.`Clientes`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Tienda`.`Clientes` (
`Password` VARCHAR(25) NOT NULL ,
`Usuario` VARCHAR(45) NOT NULL ,
`Email` VARCHAR(45) NOT NULL ,
`Telefono` VARCHAR(15) NULL ,
CONSTRAINT `ClientesVentas`
FOREIGN KEY (`Password` )
REFERENCES `Tienda`.`Ventas` (`PasswordCliente` ));


-- -----------------------------------------------------
-- Table `Tienda`.`Productos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Tienda`.`Productos` (
`idProducto` INT NOT NULL AUTO_INCREMENT ,
`idSeccion` INT NOT NULL ,
`Productos` VARCHAR(45) NOT NULL ,
`Precio` INT NOT NULL ,
`Descripcion` VARCHAR(150) NULL,
PRIMARY KEY (`idProducto`),
CONSTRAINT `ProductosVentas`
FOREIGN KEY (`idProducto` )
REFERENCES `Tienda`.`Ventas` (`idProducto` )
ON DELETE NO ACTION
ON UPDATE NO ACTION );



-- -----------------------------------------------------
-- Table `Tienda`.`Seccion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Tienda`.`Seccion` (
`idSeccion` INT NOT NULL AUTO_INCREMENT ,
`Seccion` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idSeccion`) ,
CONSTRAINT `SeccionProductos`
FOREIGN KEY (`idSeccion` )
REFERENCES `Tienda`.`Productos` (`idSeccion` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);



Me podeis ayudar?? Gracias