2016-05-26 15 views
-1

Ich erstellte das ER-Diagramm für das Student Management System und klicken Sie auf Forward Engineering und gehen Sie durch die Schritte im Dialogfeld. Aber es erscheint eine Fehlermeldung wie diese.Kann mir jemand sagen, warum bekomme ich diesen Fehler in Mysql Workbench während Forward Engineering?

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 

Kann mir jemand sagen, wo der Fehler ist und wie man ihn löst?

Antwort

2

Das Problem ist auf 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)