Answered You can hire a professional tutor to get the answer.
I keep getting this error message in the MySQL Workbench. Can somebody please take a look at the code and assist?
I keep getting this error message in the MySQL Workbench. Can somebody please take a look at the code and assist?
Error:
PRIMARY KEY (`CustomerID`, `ItemID`, `OrderDate`, `Orders_CustomerID`, `Orders_Customers_CustomerID`, `Items_ItemID`),
INDEX `(ItemID) REFERENCES Items(ItemID),_idx` (`ItemID` ASC),
CONSTRAINT `(CustomerID) REFERENCES Customers(CustomerID),`
FOREIGN KEY (`CustomerID`)
REFERENCES `CTWeek5`.`Customers` (`CustomerID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `(ItemID) REFERENCES Items(ItemID),`
FOREIGN KEY (`ItemID`)
REFERENCES `CTWeek5`.`Items` (`ItemID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `(OrderDate) REFERENCES Orders(OrderDate)`
FOREIGN KEY ()
REFERENCES `CTWeek5`.`Orders` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 8 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
BELOW IS MY SCRIPT
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema CTWeek5
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema CTWeek5
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `CTWeek5` DEFAULT CHARACTER SET utf8 ;
USE `CTWeek5` ;
-- -----------------------------------------------------
-- Table `CTWeek5`.`Customers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CTWeek5`.`Customers` (
`CustomerID` VARCHAR(10) NOT NULL,
`CustomerName` VARCHAR(50) NOT NULL,
`CustomerAddress` VARCHAR(100) NOT NULL,
PRIMARY KEY (`CustomerID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `CTWeek5`.`Items`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CTWeek5`.`Items` (
`ItemID` VARCHAR(10) NOT NULL,
`ItemDescription` VARCHAR(50) NOT NULL,
`ItemUnitCost` DECIMAL(10,2) NOT NULL,
PRIMARY KEY (`ItemID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `CTWeek5`.`Orders`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CTWeek5`.`Orders` (
`CustomerID` VARCHAR(10) NOT NULL,
`OrderDate` DATE NOT NULL,
`ShipDate` DATE NOT NULL,
`TotalOrderAmount` DECIMAL(10,2) NOT NULL,
`Customers_CustomerID` VARCHAR(10) NOT NULL,
PRIMARY KEY (`CustomerID`, `Customers_CustomerID`),
INDEX `fk_Orders_Customers_idx` (`Customers_CustomerID` ASC),
CONSTRAINT `fk_Orders_Customers`
FOREIGN KEY (`Customers_CustomerID`)
REFERENCES `CTWeek5`.`Customers` (`CustomerID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `CTWeek5`.`Order_Item`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `CTWeek5`.`Order_Item` (
`CustomerID` VARCHAR(10) NOT NULL,
`ItemID` VARCHAR(10) NOT NULL,
`OrderDate` DATE NOT NULL,
`Quantity` DECIMAL(5,0) NOT NULL,
`ItemTotal` DECIMAL(10,2) NOT NULL,
`Orders_CustomerID` VARCHAR(10) NOT NULL,
`Orders_Customers_CustomerID` VARCHAR(10) NOT NULL,
`Items_ItemID` VARCHAR(10) NOT NULL,
PRIMARY KEY (`CustomerID`, `ItemID`, `OrderDate`, `Orders_CustomerID`, `Orders_Customers_CustomerID`, `Items_ItemID`),
INDEX `(ItemID) REFERENCES Items(ItemID),_idx` (`ItemID` ASC),
CONSTRAINT `(CustomerID) REFERENCES Customers(CustomerID),`
FOREIGN KEY (`CustomerID`)
REFERENCES `CTWeek5`.`Customers` (`CustomerID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `(ItemID) REFERENCES Items(ItemID),`
FOREIGN KEY (`ItemID`)
REFERENCES `CTWeek5`.`Items` (`ItemID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `(OrderDate) REFERENCES Orders(OrderDate)`
FOREIGN KEY ()
REFERENCES `CTWeek5`.`Orders` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;