MySQL Forums
Forum List  »  MySQL Workbench

The generated sql for my database has an error?
Posted by: Brian O'Brien
Date: July 12, 2009 12:22PM

I'm having difficulty getting my sql to execute properly... There is an error message being generated by mysql due to the sql I am trying to execute...

I think there is something wrong with a foreign key statement...
I wish I could attach my project files here...

Here is the sql..

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';

CREATE SCHEMA IF NOT EXISTS `BrainTumorDatabase` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `BrainTumorDatabase`;

-- -----------------------------------------------------
-- Table `BrainTumorDatabase`.`PatientTable`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `BrainTumorDatabase`.`PatientTable` ;

CREATE TABLE IF NOT EXISTS `BrainTumorDatabase`.`PatientTable` (
`FirstName` VARCHAR(32) NOT NULL ,
`MiddleName` VARCHAR(32) NULL ,
`LastName` VARCHAR(32) NOT NULL ,
`DateOfBirth` DATE NOT NULL ,
`Sex` CHAR NOT NULL ,
`PatientID` VARCHAR(32) NOT NULL ,
PRIMARY KEY (`PatientID`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `BrainTumorDatabase`.`SurgeryTable`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `BrainTumorDatabase`.`SurgeryTable` ;

CREATE TABLE IF NOT EXISTS `BrainTumorDatabase`.`SurgeryTable` (
`Description` VARCHAR(128) NOT NULL ,
`DateOfSurgery` DATE NOT NULL ,
`SurgeryID` VARCHAR(45) NOT NULL ,
`PatientID` VARCHAR(32) NOT NULL ,
PRIMARY KEY (`SurgeryID`) ,
INDEX `PatientID` () ,
CONSTRAINT `PatientID`
FOREIGN KEY ()
REFERENCES `BrainTumorDatabase`.`PatientTable` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


This is generating an error message:

You have an error in your AQL syntax; check the manual that....
to use near '), CONSTRAINT `PatientID`
FOREIGN KEY()
REFRENCES `BrainTumorDatabase`.`Pati` at line 7


I designed a database with a few tables... the primary table is the PatientTable
subsequent tables have entries where the foreign key is the patientID...

Options: ReplyQuote


Subject
Views
Written By
Posted
The generated sql for my database has an error?
2442
July 12, 2009 12:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.