title: foreign key in mysql workbench
body: <p>i am beginner in mysql and have a simple question.
  i have three tables in my schema(bookshop). i want to have a relationship between them.
  my tables: books(book_id,book_name,book_entity),customer(customer_id,customer_name),orders(book_id,customer_id,quantity).
  i set the foreign key in orders table as following:</p>
  
  <p><strong>foreign key names(book_id and customer_id ) ,             reference table(
                         'bookshop','books'
                    'bookshop','customer')</strong></p>
  
  <p>at first i fill the books table,but when i am trying to insert data in customer table i have following error:</p>
  
  <pre><code>  ERROR 1452: Cannot add or update a child row: a foreign key constraint fails (`bookshop`.`customer`, CONSTRAINT `customer_id` FOREIGN KEY (`customer_id`) REFERENCES `order` (`customer_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
  
  SQL Statement:
  
  INSERT INTO `bookshop`.`customer` (`customer_id`, `customer_name`, `customer_address`) VALUES (2, 'helen', 'newyork')
  </code></pre>
  
  <p>what shall i do?</p>
  
  <p>my codes:</p>
  
  <hr>
  
  <pre><code>-- Table `bookshop`.`books`
  
  -- -----------------------------------------------------
  
  CREATE  TABLE IF NOT EXISTS `bookshop`.`books` (
  
    `book_id` INT NOT NULL ,
  
    `book_name` VARCHAR(45) NOT NULL ,
  
    `book_price` DECIMAL NOT NULL ,
  
    `book_entity` INT NOT NULL ,
  
    PRIMARY KEY (`book_id`) )
  
  ENGINE = InnoDB;
  
  
  
  
  
  -- -----------------------------------------------------
  
  -- Table `bookshop`.`customer`
  
  -- -----------------------------------------------------
  
  CREATE  TABLE IF NOT EXISTS `bookshop`.`customer` (
  
    `customer_id` INT NOT NULL ,
  
    `customer_name` VARCHAR(45) NOT NULL ,
  
    `customer_address` VARCHAR(45) NOT NULL ,
  
    PRIMARY KEY (`customer_id`) )
  
  ENGINE = InnoDB;
  
  
  
  
  
  -- -----------------------------------------------------
  
  -- Table `bookshop`.`orders`
  
  -- -----------------------------------------------------
  
  CREATE  TABLE IF NOT EXISTS `bookshop`.`orders` (
  
    `book_id` INT NOT NULL ,
  
    `customer_id` INT NOT NULL ,
  
    `quantity` INT NOT NULL ,
  
    INDEX `book_id` (`book_id` ASC) ,
  
    INDEX `customer_id` (`customer_id` ASC) ,
  
    CONSTRAINT `book_id`
  
      FOREIGN KEY (`book_id` )
  
      REFERENCES `bookshop`.`books` (`book_id` )
  
      ON DELETE NO ACTION
  
      ON UPDATE NO ACTION,
  
    CONSTRAINT `customer_id`
  
      FOREIGN KEY (`customer_id` )
  
      REFERENCES `bookshop`.`customer` (`customer_id` )
  
      ON DELETE RESTRICT
  
      ON UPDATE RESTRICT)
  
  ENGINE = InnoDB;
  </code></pre>