text: -- MySQL Script generated by MySQL Workbench
  -- Sun Apr 19 20:36:48 2020
  -- 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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
  
  -- -----------------------------------------------------
  -- Schema mydb
  -- -----------------------------------------------------
  -- -----------------------------------------------------
  -- Schema CSC425
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema CSC425
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `CSC425` DEFAULT CHARACTER SET utf8mb4 ;
  USE `CSC425` ;
  
  -- -----------------------------------------------------
  -- Table `CSC425`.`Users`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `CSC425`.`Users` ;
  
  CREATE TABLE IF NOT EXISTS `CSC425`.`Users` (
    `UserID` INT(11) NOT NULL AUTO_INCREMENT,
    `Username` VARCHAR(50) NOT NULL,
    `EmailAddress` VARCHAR(256) NOT NULL,
    `Password` VARCHAR(256) NOT NULL,
    `Salt` VARCHAR(256) NOT NULL,
    `UserRole` VARCHAR(45) NOT NULL,
    `CreationIP` VARCHAR(256) NOT NULL,
    `VerificationIP` VARCHAR(256) NOT NULL,
    `Use2FA` TINYINT(1) NOT NULL,
    `LoginAttempts` INT(11) NOT NULL,
    `SessionID` LONGTEXT NULL DEFAULT NULL,
    `SecretKey` LONGTEXT NULL DEFAULT NULL,
    `Secret2FA` LONGTEXT NULL DEFAULT NULL,
    `IsVerified` TINYINT(4) NULL DEFAULT '0',
    `Gender` VARCHAR(45) NULL DEFAULT NULL,
    `Birthday` DATETIME NULL DEFAULT NULL,
    PRIMARY KEY (`UserID`))
  ENGINE = InnoDB
  AUTO_INCREMENT = 6
  DEFAULT CHARACTER SET = utf8mb4;
  
  
  -- -----------------------------------------------------
  -- Table `CSC425`.`Logins`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `CSC425`.`Logins` ;
  
  CREATE TABLE IF NOT EXISTS `CSC425`.`Logins` (
    `LoginsID` INT(11) NOT NULL AUTO_INCREMENT,
    `UsersID` INT(11) NOT NULL,
    `IPAddress` VARCHAR(50) NOT NULL,
    `LoginDate` DATETIME NOT NULL,
    `Used2FA` TINYINT(4) NOT NULL,
    PRIMARY KEY (`LoginsID`),
    INDEX `UserID_Login_FK` (`UsersID` ASC) VISIBLE,
    CONSTRAINT `UserID_Login_FK`
      FOREIGN KEY (`UsersID`)
      REFERENCES `CSC425`.`Users` (`UserID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8mb4;
  
  
  -- -----------------------------------------------------
  -- Table `CSC425`.`Notes`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `CSC425`.`Notes` ;
  
  CREATE TABLE IF NOT EXISTS `CSC425`.`Notes` (
    `NotesID` INT(11) NOT NULL AUTO_INCREMENT,
    `UserID` INT(11) NOT NULL,
    `ClassID` VARCHAR(50) NULL DEFAULT NULL,
    `Note` LONGTEXT NOT NULL,
    `NoteFile` BLOB NOT NULL,
    `NoteFileName` LONGTEXT NOT NULL,
    `Extension` VARCHAR(10) NOT NULL,
    `NoteDate` DATETIME NOT NULL,
    `UploadDate` DATETIME NOT NULL,
    PRIMARY KEY (`NotesID`),
    INDEX `UserID_Note_FK` (`UserID` ASC) VISIBLE,
    CONSTRAINT `UserID_Note_FK`
      FOREIGN KEY (`UserID`)
      REFERENCES `CSC425`.`Users` (`UserID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8mb4;
  
  
  -- -----------------------------------------------------
  -- Table `CSC425`.`Note_Viewers`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `CSC425`.`Note_Viewers` ;
  
  CREATE TABLE IF NOT EXISTS `CSC425`.`Note_Viewers` (
    `NoteViewerID` INT(11) NOT NULL AUTO_INCREMENT,
    `NoteID` INT(11) NOT NULL,
    `UserID` INT(11) NOT NULL,
    PRIMARY KEY (`NoteViewerID`),
    INDEX `Note_Author_ID_FK` (`NoteID` ASC) VISIBLE,
    INDEX `Note_Authorized_Viewer_ID_FK` (`UserID` ASC) VISIBLE,
    CONSTRAINT `Note_Author_ID_FK`
      FOREIGN KEY (`NoteID`)
      REFERENCES `CSC425`.`Notes` (`NotesID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `Note_Authorized_Viewer_ID_FK`
      FOREIGN KEY (`UserID`)
      REFERENCES `CSC425`.`Users` (`UserID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8mb4;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  