Sei sulla pagina 1di 6

-- MySQL Script generated by MySQL Workbench

-- Wed Mar 11 14:18:00 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,ERRO
R_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

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

-- Schema NPC

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

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

-- Schema NPC

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

CREATE SCHEMA IF NOT EXISTS `NPC` DEFAULT CHARACTER SET utf8 ;

USE `NPC` ;

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

-- Table `NPC`.`scoremarks`

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

CREATE TABLE IF NOT EXISTS `NPC`.`scoremarks` (

`idscoremarks` INT NOT NULL,

`Sid` INT NULL,

`marks` INT NULL,

`scoremarkscol` VARCHAR(45) NULL,


PRIMARY KEY (`idscoremarks`))

ENGINE = InnoDB;

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

-- Table `NPC`.`students`

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

CREATE TABLE IF NOT EXISTS `NPC`.`students` (

`idstudents` INT NOT NULL,

`Snames` VARCHAR(45) NULL,

`age` INT NULL,

`studentscol` VARCHAR(45) NULL,

`scoremarks_idscoremarks` INT NOT NULL,

PRIMARY KEY (`idstudents`),

INDEX `fk_students_scoremarks1_idx` (`scoremarks_idscoremarks` ASC) VISIBLE,

CONSTRAINT `fk_students_scoremarks1`

FOREIGN KEY (`scoremarks_idscoremarks`)

REFERENCES `NPC`.`scoremarks` (`idscoremarks`)

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB;

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

-- Table `NPC`.`department`

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

CREATE TABLE IF NOT EXISTS `NPC`.`department` (

`iddepartment` INT NOT NULL,

`departmentname` VARCHAR(45) NULL,


`idlecture` INT NULL,

`departmentcol` VARCHAR(45) NULL,

PRIMARY KEY (`iddepartment`))

ENGINE = InnoDB;

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

-- Table `NPC`.`lecture`

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

CREATE TABLE IF NOT EXISTS `NPC`.`lecture` (

`idlecture` INT NOT NULL,

`lecturename` VARCHAR(45) NULL,

`Cid` INT NULL,

`lecturecol` VARCHAR(45) NULL,

`department_iddepartment` INT NOT NULL,

PRIMARY KEY (`idlecture`),

INDEX `fk_lecture_department1_idx` (`department_iddepartment` ASC) VISIBLE,

CONSTRAINT `fk_lecture_department1`

FOREIGN KEY (`department_iddepartment`)

REFERENCES `NPC`.`department` (`iddepartment`)

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB;

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

-- Table `NPC`.`courses_has_students`

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

CREATE TABLE IF NOT EXISTS `NPC`.`courses_has_students` (


`courses_idcourses` INT NOT NULL,

`students_idstudents` INT NOT NULL,

`students_idstudents1` INT NOT NULL,

PRIMARY KEY (`courses_idcourses`, `students_idstudents`, `students_idstudents1`),

INDEX `fk_courses_has_students_students1_idx` (`students_idstudents` ASC) VISIBLE,

INDEX `fk_courses_has_students_courses1_idx` (`courses_idcourses` ASC) VISIBLE,

INDEX `fk_courses_has_students_students2_idx` (`students_idstudents1` ASC) VISIBLE,

CONSTRAINT `fk_courses_has_students_courses1`

FOREIGN KEY (`courses_idcourses`)

REFERENCES `NPC`.`courses` (`idcourses`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `fk_courses_has_students_students1`

FOREIGN KEY (`students_idstudents`)

REFERENCES `NPC`.`students` (`idstudents`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `fk_courses_has_students_students2`

FOREIGN KEY (`students_idstudents1`)

REFERENCES `NPC`.`students` (`idstudents`)

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB;

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

-- Table `NPC`.`courses`

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

CREATE TABLE IF NOT EXISTS `NPC`.`courses` (


`idcourses` INT NOT NULL,

`Cname` VARCHAR(45) NULL,

`idstudent` INT NULL,

`coursescol` VARCHAR(45) NULL,

`lecture_idlecture` INT NOT NULL,

`courses_has_students_courses_idcourses` INT NOT NULL,

`courses_has_students_students_idstudents` INT NOT NULL,

`scoremarks_idscoremarks` INT NOT NULL,

PRIMARY KEY (`idcourses`, `courses_has_students_courses_idcourses`,


`courses_has_students_students_idstudents`),

INDEX `fk_courses_lecture_idx` (`lecture_idlecture` ASC) VISIBLE,

INDEX `fk_courses_courses_has_students1_idx` (`courses_has_students_courses_idcourses` ASC,


`courses_has_students_students_idstudents` ASC) VISIBLE,

INDEX `fk_courses_scoremarks1_idx` (`scoremarks_idscoremarks` ASC) VISIBLE,

CONSTRAINT `fk_courses_lecture`

FOREIGN KEY (`lecture_idlecture`)

REFERENCES `NPC`.`lecture` (`idlecture`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `fk_courses_courses_has_students1`

FOREIGN KEY (`courses_has_students_courses_idcourses` ,


`courses_has_students_students_idstudents`)

REFERENCES `NPC`.`courses_has_students` (`courses_idcourses` , `students_idstudents`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `fk_courses_scoremarks1`

FOREIGN KEY (`scoremarks_idscoremarks`)

REFERENCES `NPC`.`scoremarks` (`idscoremarks`)

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;