I created the ER diagram for the student management system and click the forward engineering and go through the steps in dialog box. But it shows up error message like this.
Executing SQL script in server
ERROR: Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key
SQL Code:
-- -----------------------------------------------------
-- Table `SLIOP`.`course`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `SLIOP`.`course` (
`courseNo` INT NOT NULL AUTO_INCREMENT,
`courseID` VARCHAR(10) NOT NULL,
`course_name` VARCHAR(40) NOT NULL,
`course_type` VARCHAR(25) NOT NULL,
`content_type` VARCHAR(20) NOT NULL,
`lecturer_name` VARCHAR(40) NOT NULL,
`time` TIMESTAMP NOT NULL,
`fee` DECIMAL(10,2) NOT NULL,
`no_classes` INT NOT NULL,
`no_students` INT NOT NULL,
`requirement` MEDIUMTEXT NOT NULL,
`lecturerID` INT NOT NULL,
PRIMARY KEY (`courseID`),
INDEX `fk_course_academic_staff1_idx` (`lecturerID` ASC),
CONSTRAINT `fk_course_academic_staff1`
FOREIGN KEY (`lecturerID`)
REFERENCES `SLIOP`.`academic_staff` (`lecturerID`)
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
Can someone tell my where is the error and how to solve it?
The problem is on PRIMARY KEY
CREATE TABLE IF NOT EXISTS `SLIOP`.`course` (
`courseNo` INT NOT NULL AUTO_INCREMENT,
`courseID` VARCHAR(10) NOT NULL,
`course_name` VARCHAR(40) NOT NULL,
`course_type` VARCHAR(25) NOT NULL,
`content_type` VARCHAR(20) NOT NULL,
`lecturer_name` VARCHAR(40) NOT NULL,
`time` TIMESTAMP NOT NULL,
`fee` DECIMAL(10,2) NOT NULL,
`no_classes` INT NOT NULL,
`no_students` INT NOT NULL,
`requirement` MEDIUMTEXT NOT NULL,
`lecturerID` INT NOT NULL,
PRIMARY KEY (`courseNo`),
INDEX `fk_course_academic_staff1_idx` (`lecturerID` ASC),
CONSTRAINT `fk_course_academic_staff1`
FOREIGN KEY (`lecturerID`)
REFERENCES `SLIOP`.`academic_staff` (`lecturerID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)