View the step-by-step solution to:

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 @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;

SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

SET @[email protected]@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 [email protected]_SQL_MODE;

SET [email protected]_FOREIGN_KEY_CHECKS;

SET [email protected]_UNIQUE_CHECKS;

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question