text: -- MySQL Script generated by MySQL Workbench
  -- Mon Oct 28 17:48:58 2019
  -- Model: New Model    Version: 1.0
  -- 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='TRADITIONAL,ALLOW_INVALID_DATES';
  
  -- -----------------------------------------------------
  -- Schema Project
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema Project
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `Project` DEFAULT CHARACTER SET utf8 ;
  USE `Project` ;
  
  -- -----------------------------------------------------
  -- Table `Project`.`courses`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`courses` (
    `courseID` INT NOT NULL,
    `courseCode` VARCHAR(45) NOT NULL,
    `courseName` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`courseID`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`building`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`building` (
    `buildingID` INT NOT NULL,
    `buildingName` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`buildingID`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`room`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`room` (
    `roomID` INT NOT NULL,
    `location` VARCHAR(255) NOT NULL,
    `buildingID` INT NOT NULL,
    PRIMARY KEY (`roomID`, `buildingID`),
    INDEX `fk_room_building1_idx` (`buildingID` ASC),
    CONSTRAINT `fk_room_building1`
      FOREIGN KEY (`buildingID`)
      REFERENCES `Project`.`building` (`buildingID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`role`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`role` (
    `roleID` INT NOT NULL AUTO_INCREMENT,
    `roleName` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`roleID`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`user`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`user` (
    `userID` INT NOT NULL,
    `userName` VARCHAR(45) NOT NULL,
    `password` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`userID`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`lecturers`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`lecturers` (
    `lecturerID` INT NOT NULL,
    `firstName` VARCHAR(45) NOT NULL,
    `lastName` VARCHAR(45) NOT NULL,
    `email` VARCHAR(45) NOT NULL,
    `phoneNumber` INT(10) NOT NULL,
    `roleID` INT NOT NULL,
    `userID` INT NOT NULL,
    PRIMARY KEY (`lecturerID`, `roleID`, `userID`),
    INDEX `fk_lecturers_role1_idx` (`roleID` ASC),
    INDEX `fk_lecturers_user1_idx` (`userID` ASC),
    CONSTRAINT `fk_lecturers_role1`
      FOREIGN KEY (`roleID`)
      REFERENCES `Project`.`role` (`roleID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_lecturers_user1`
      FOREIGN KEY (`userID`)
      REFERENCES `Project`.`user` (`userID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`students`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`students` (
    `studentID` INT NOT NULL,
    `firstName` VARCHAR(45) NOT NULL,
    `lastName` VARCHAR(45) NOT NULL,
    `email` VARCHAR(45) NOT NULL,
    `phone` VARCHAR(10) NOT NULL,
    `userID` INT NOT NULL,
    PRIMARY KEY (`studentID`, `userID`),
    INDEX `fk_students_user1_idx` (`userID` ASC),
    CONSTRAINT `fk_students_user1`
      FOREIGN KEY (`userID`)
      REFERENCES `Project`.`user` (`userID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.``
  -- -----------------------------------------------------
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`admin`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`admin` (
    `adminID` INT NOT NULL,
    `firstName` VARCHAR(45) NOT NULL,
    `lastName` VARCHAR(45) NOT NULL,
    `email` VARCHAR(45) NOT NULL,
    `phone` VARCHAR(10) NOT NULL,
    `userID` INT NOT NULL,
    PRIMARY KEY (`adminID`, `userID`),
    INDEX `fk_admin_user1_idx` (`userID` ASC),
    CONSTRAINT `fk_admin_user1`
      FOREIGN KEY (`userID`)
      REFERENCES `Project`.`user` (`userID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`parent`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`parent` (
    `parentID` INT NOT NULL,
    `firstName` VARCHAR(45) NOT NULL,
    `lastName` VARCHAR(45) NOT NULL,
    `phone` VARCHAR(10) NOT NULL,
    `userID` INT NOT NULL,
    PRIMARY KEY (`parentID`, `userID`),
    INDEX `fk_parent_user1_idx` (`userID` ASC),
    CONSTRAINT `fk_parent_user1`
      FOREIGN KEY (`userID`)
      REFERENCES `Project`.`user` (`userID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`studentsRegeter`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`studentsRegeter` (
    `courseID` INT NOT NULL,
    `studentID` INT NOT NULL,
    `datetimeRegeter` DATETIME NOT NULL,
    PRIMARY KEY (`courseID`, `studentID`),
    INDEX `fk_courses_has_students_students1_idx` (`studentID` ASC),
    INDEX `fk_courses_has_students_courses1_idx` (`courseID` ASC),
    CONSTRAINT `fk_courses_has_students_courses1`
      FOREIGN KEY (`courseID`)
      REFERENCES `Project`.`courses` (`courseID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_courses_has_students_students1`
      FOREIGN KEY (`studentID`)
      REFERENCES `Project`.`students` (`studentID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`teaching`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`teaching` (
    `courseID` INT NOT NULL,
    `lecturerID` INT NOT NULL,
    `roleID` INT NOT NULL,
    PRIMARY KEY (`courseID`, `lecturerID`, `roleID`),
    INDEX `fk_courses_has_lecturers_lecturers1_idx` (`lecturerID` ASC, `roleID` ASC),
    INDEX `fk_courses_has_lecturers_courses1_idx` (`courseID` ASC),
    CONSTRAINT `fk_courses_has_lecturers_courses1`
      FOREIGN KEY (`courseID`)
      REFERENCES `Project`.`courses` (`courseID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_courses_has_lecturers_lecturers1`
      FOREIGN KEY (`lecturerID` , `roleID`)
      REFERENCES `Project`.`lecturers` (`lecturerID` , `roleID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`class`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`class` (
    `courseID` INT NOT NULL,
    `roomID` INT NOT NULL,
    `datetimeStudy` DATETIME NOT NULL,
    PRIMARY KEY (`courseID`, `roomID`),
    INDEX `fk_courses_has_room_room1_idx` (`roomID` ASC),
    INDEX `fk_courses_has_room_courses1_idx` (`courseID` ASC),
    CONSTRAINT `fk_courses_has_room_courses1`
      FOREIGN KEY (`courseID`)
      REFERENCES `Project`.`courses` (`courseID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_courses_has_room_room1`
      FOREIGN KEY (`roomID`)
      REFERENCES `Project`.`room` (`roomID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `Project`.`checkName`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `Project`.`checkName` (
    `courseID` INT NOT NULL,
    `roomID` INT NOT NULL,
    `studentID` INT NOT NULL,
    `datetime` DATETIME NOT NULL,
    `status` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`courseID`, `roomID`, `studentID`),
    INDEX `fk_class_has_studentsRegeter_studentsRegeter1_idx` (`studentID` ASC),
    INDEX `fk_class_has_studentsRegeter_class1_idx` (`courseID` ASC, `roomID` ASC),
    CONSTRAINT `fk_class_has_studentsRegeter_class1`
      FOREIGN KEY (`courseID` , `roomID`)
      REFERENCES `Project`.`class` (`courseID` , `roomID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_class_has_studentsRegeter_studentsRegeter1`
      FOREIGN KEY (`studentID`)
      REFERENCES `Project`.`studentsRegeter` (`studentID`)
      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;
  