Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MySQL Workbench Executing Script on Server -------------------------------------------------------------------------------- Server type: MySQL Server version: 8.0 - MySQL Community Server(GPL) MySQL Workbench 8.0 CE ----------------------------------------------------------------------------------- Please correct the

MySQL Workbench Executing Script on Server

--------------------------------------------------------------------------------

Server type: MySQL

Server version: 8.0 - MySQL Community Server(GPL)

MySQL Workbench 8.0 CE

-----------------------------------------------------------------------------------

Please correct the syntax errors in the Message Log below. Below is the SQL Script first, and then the Message Log which I have separated.

------------------------------------------------------------------------------------

-- 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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- ----------------------------------------------------- -- Schema mydb -- -----------------------------------------------------

-- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ; USE `mydb` ;

-- ----------------------------------------------------- -- Table `mydb`.`doctors` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`doctors` ( `DoctorKey` INT(11) NOT NULL, `DoctorName` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`DoctorKey`)) ENGINE = InnoDB;

-- ----------------------------------------------------- -- Table `mydb`.`Patients` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Patients` ( `PatientKey` INT(11) NOT NULL, `FirstName` VARCHAR(45) NULL, `MiddleName` VARCHAR(45) NULL, `LastName` VARCHAR(45) NULL, `PhoneNumber` VARCHAR(20) NULL, `doctors_DoctorKey` INT(11) NOT NULL, PRIMARY KEY (`PatientKey`), INDEX `fk_Patients_doctors1_idx` (`doctors_DoctorKey` ASC) VISIBLE, CONSTRAINT `fk_Patients_doctors1` FOREIGN KEY (`doctors_DoctorKey`) REFERENCES `mydb`.`doctors` (`DoctorKey`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB;

-- ----------------------------------------------------- -- Table `mydb`.`droppedPatients` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`droppedPatients` ( `PatientKey` INT(11) NOT NULL, `DatesDropped` DATE NULL, `ReasonDropped` VARCHAR(200) NULL, PRIMARY KEY (`PatientKey`), CONSTRAINT `fk_Patients_DroppedPatients` FOREIGN KEY (PatientKey) REFERENCES `mydb`.`Patients` (PatientKey) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB;

-- ----------------------------------------------------- -- Table `mydb`.`Groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`Groups` ( `GroupKey` INT(11) NOT NULL, `GroupDescription` VARCHAR(100) NULL, PRIMARY KEY (`GroupKey`)) ENGINE = InnoDB;

-- ----------------------------------------------------- -- Table `mydb`.`patients_has_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`patients_has_groups` ( `Patients_PatientKey` INT(11) NOT NULL, `Groups_GroupKey` INT(11) NOT NULL, PRIMARY KEY (`Patients_PatientKey`, `Groups_GroupKey`), CONSTRAINT `fk_Groups_has_Patients_Groups1` FOREIGN KEY () REFERENCES `mydb`.`Groups` () ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Groups_has_Patients_Patients1` FOREIGN KEY () REFERENCES `mydb`.`Patients` () 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;

------------------------------------------------------------------------------------

SEPARATION

------------------------------------------------------------------------------------

Executing SQL script in server ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') REFERENCES `mydb`.`Patients` () ON DELETE NO ACTION ON UPDATE NO A' at line 10 SQL Code: -- ----------------------------------------------------- -- Table `mydb`.`droppedPatients` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`droppedPatients` ( `PatientKey` INT(11) NOT NULL, `DatesDropped` DATE NULL, `ReasonDropped` VARCHAR(200) NULL, PRIMARY KEY (`PatientKey`), CONSTRAINT `fk_Patients_DroppedPatients` FOREIGN KEY () REFERENCES `mydb`.`Patients` () ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB

SQL script execution finished: statements: 7 succeeded, 1 failed

Fetching back view definitions in final form. Nothing to fetch Executing SQL script in server ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') REFERENCES `mydb`.`Groups` () ON DELETE NO ACTION ON UPDATE NO ACT' at line 9 SQL Code: -- ----------------------------------------------------- -- Table `mydb`.`patients_has_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`patients_has_groups` ( `Patients_PatientKey` INT(11) NOT NULL, `Groups_GroupKey` INT(11) NOT NULL, PRIMARY KEY (`Patients_PatientKey`, `Groups_GroupKey`), CONSTRAINT `fk_Groups_has_Patients_Groups1` FOREIGN KEY () REFERENCES `mydb`.`Groups` () ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Groups_has_Patients_Patients1` FOREIGN KEY () REFERENCES `mydb`.`Patients` () ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB

SQL script execution finished: statements: 9 succeeded, 1 failed

Fetching back view definitions in final form. Nothing to fetch

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions