2

我有一个错误:

无法创建表“e-learningsystem.chapter”(错误号:121)

在进行工程时,请帮我解决问题

这些是我数据库中的表:

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



CREATE SCHEMA IF NOT EXISTS `E-LearningSystem` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;

USE `E-LearningSystem` ;



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

-- Table `E-LearningSystem`.`Admin`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Admin` (

  `AdminID` INT NOT NULL AUTO_INCREMENT ,

  `Name` VARCHAR(45) NOT NULL ,

  `UserName` VARCHAR(45) NOT NULL ,

  `Password` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`AdminID`) )

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`Semester`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Semester` (

  `SemesterID` INT NOT NULL AUTO_INCREMENT ,

  `YearID` INT NOT NULL ,

  `SemeID` INT NOT NULL ,

  PRIMARY KEY (`SemesterID`) )

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`Lecturer`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Lecturer` (

  `LecturerID` INT NOT NULL AUTO_INCREMENT ,

  `Name` VARCHAR(45) NOT NULL ,

  `Address` VARCHAR(45) NOT NULL ,

  `ContactNo` INT NOT NULL ,

  `UserName` VARCHAR(45) NOT NULL ,

  `Password` VARCHAR(45) NOT NULL ,

  `email` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`LecturerID`) )

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`Subject`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Subject` (

  `SubjectID` INT NOT NULL AUTO_INCREMENT ,

  `Name` VARCHAR(45) NOT NULL ,

  `SemesterID` INT NOT NULL ,

  `LecturerID` INT NOT NULL ,

  PRIMARY KEY (`SubjectID`) ,

  UNIQUE INDEX `SemesterID_UNIQUE` (`SemesterID` ASC) ,

  UNIQUE INDEX `LecturerID_UNIQUE` (`LecturerID` ASC) ,

  CONSTRAINT `SemesterID`

    FOREIGN KEY (`SemesterID` )

    REFERENCES `E-LearningSystem`.`Semester` (`SemesterID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `LecturerID`

    FOREIGN KEY (`LecturerID` )

    REFERENCES `E-LearningSystem`.`Lecturer` (`LecturerID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`Student`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Student` (

  `StudentID` INT NOT NULL AUTO_INCREMENT ,

  `Name` VARCHAR(45) NOT NULL ,

  `EP_No` VARCHAR(45) NOT NULL ,

  `UserName` VARCHAR(45) NOT NULL ,

  `Password` VARCHAR(45) NOT NULL ,

  `email` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`StudentID`) )

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`RegisteredStudent`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`RegisteredStudent` (

  `RegisteredStudentID` INT NOT NULL AUTO_INCREMENT ,

  `SubjectID` INT NOT NULL ,

  `StudentID` INT NOT NULL ,

  `Quiz1` INT NULL ,

  `Quiz2` INT NULL ,

  `Quiz3` INT NULL ,

  `Quiz4` INT NULL ,

  `Assignment1` INT NULL ,

  `Assignment2` INT NULL ,

  `Mid` INT NOT NULL ,

  PRIMARY KEY (`RegisteredStudentID`) ,

  UNIQUE INDEX `SubjectID_UNIQUE` (`SubjectID` ASC) ,

  UNIQUE INDEX `StudentID_UNIQUE` (`StudentID` ASC) ,

  CONSTRAINT `SubjectID`

    FOREIGN KEY (`SubjectID` )

    REFERENCES `E-LearningSystem`.`Subject` (`SubjectID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `StudentID`

    FOREIGN KEY (`StudentID` )

    REFERENCES `E-LearningSystem`.`Student` (`StudentID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





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

-- Table `E-LearningSystem`.`Chapter`

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

CREATE  TABLE IF NOT EXISTS `E-LearningSystem`.`Chapter` (

  `ChapterID` INT NOT NULL AUTO_INCREMENT ,

  `Name` VARCHAR(45) NOT NULL ,

  `Document` VARCHAR(45) NOT NULL ,

  `SubjectID` INT NOT NULL ,

  PRIMARY KEY (`ChapterID`) ,

  UNIQUE INDEX `SubjectID_UNIQUE` (`SubjectID` ASC) ,

  CONSTRAINT `SubjectID`

    FOREIGN KEY (`SubjectID` )

    REFERENCES `E-LearningSystem`.`Subject` (`SubjectID` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;



USE `E-LearningSystem` ;





SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
4

0 回答 0