SHARE
TWEET

Untitled

a guest Jun 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MySQL Script generated by MySQL Workbench
  2. -- Thu Jun 20 20:14:23 2019
  3. -- Model: New Model    Version: 1.0
  4. -- MySQL Workbench Forward Engineering
  5.  
  6. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  7. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  8. 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';
  9.  
  10. -- -----------------------------------------------------
  11. -- Schema mydb
  12. -- -----------------------------------------------------
  13.  
  14. -- -----------------------------------------------------
  15. -- Schema mydb
  16. -- -----------------------------------------------------
  17. CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
  18. USE `mydb` ;
  19.  
  20. -- -----------------------------------------------------
  21. -- Table `mydb`.`AJAsistent`
  22. -- -----------------------------------------------------
  23. CREATE TABLE IF NOT EXISTS `mydb`.`AJAsistent` (
  24.   `idAsistent` INT NOT NULL,
  25.   `ime` VARCHAR(20) NOT NULL,
  26.   `prezime` VARCHAR(20) NOT NULL,
  27.   `username` VARCHAR(15) NOT NULL,
  28.   PRIMARY KEY (`idAsistent`))
  29. ENGINE = InnoDB;
  30.  
  31.  
  32. -- -----------------------------------------------------
  33. -- Table `mydb`.`AJStudent`
  34. -- -----------------------------------------------------
  35. CREATE TABLE IF NOT EXISTS `mydb`.`AJStudent` (
  36.   `idStudent` INT GENERATED ALWAYS AS () VIRTUAL,
  37.   `brojIndeksa` INT NOT NULL,
  38.   `ime` VARCHAR(20) NOT NULL,
  39.   `Prezime` VARCHAR(20) NOT NULL,
  40.   `datumR` DATE NOT NULL,
  41.   `username` VARCHAR(15) NOT NULL,
  42.   PRIMARY KEY (`idStudent`))
  43. ENGINE = InnoDB;
  44.  
  45.  
  46. -- -----------------------------------------------------
  47. -- Table `mydb`.`AJProfesor`
  48. -- -----------------------------------------------------
  49. CREATE TABLE IF NOT EXISTS `mydb`.`AJProfesor` (
  50.   `idProfesor` INT GENERATED ALWAYS AS () VIRTUAL,
  51.   `ime` VARCHAR(45) NOT NULL,
  52.   `prezime` VARCHAR(45) NOT NULL,
  53.   `zvanje` VARCHAR(45) NOT NULL,
  54.   `username` VARCHAR(15) NOT NULL,
  55.   PRIMARY KEY (`idProfesor`))
  56. ENGINE = InnoDB;
  57.  
  58.  
  59. -- -----------------------------------------------------
  60. -- Table `mydb`.`AJPredmet`
  61. -- -----------------------------------------------------
  62. CREATE TABLE IF NOT EXISTS `mydb`.`AJPredmet` (
  63.   `idPredmet` INT NOT NULL,
  64.   `naziv` VARCHAR(20) NOT NULL,
  65.   `Asistent_idAsistent` INT NOT NULL,
  66.   `Profesor_idProfesor` INT NOT NULL,
  67.   PRIMARY KEY (`idPredmet`),
  68.   INDEX `fk_Predmet_Asistent1_idx` (`Asistent_idAsistent` ASC),
  69.   INDEX `fk_Predmet_Profesor1_idx` (`Profesor_idProfesor` ASC),
  70.   CONSTRAINT `fk_Predmet_Asistent1`
  71.     FOREIGN KEY (`Asistent_idAsistent`)
  72.     REFERENCES `mydb`.`AJAsistent` (`idAsistent`)
  73.     ON DELETE NO ACTION
  74.     ON UPDATE NO ACTION,
  75.   CONSTRAINT `fk_Predmet_Profesor1`
  76.     FOREIGN KEY (`Profesor_idProfesor`)
  77.     REFERENCES `mydb`.`AJProfesor` (`idProfesor`)
  78.     ON DELETE NO ACTION
  79.     ON UPDATE NO ACTION)
  80. ENGINE = InnoDB;
  81.  
  82.  
  83. -- -----------------------------------------------------
  84. -- Table `mydb`.`AJTest`
  85. -- -----------------------------------------------------
  86. CREATE TABLE IF NOT EXISTS `mydb`.`AJTest` (
  87.   `idSemaTest` INT NOT NULL,
  88.   `AJPredmet_idPredmet` INT NOT NULL,
  89.   `imeTesta` VARCHAR(20) NOT NULL,
  90.   PRIMARY KEY (`idSemaTest`),
  91.   INDEX `fk_AJSemaTest_AJPredmet1_idx` (`AJPredmet_idPredmet` ASC),
  92.   CONSTRAINT `fk_AJSemaTest_AJPredmet1`
  93.     FOREIGN KEY (`AJPredmet_idPredmet`)
  94.     REFERENCES `mydb`.`AJPredmet` (`idPredmet`)
  95.     ON DELETE NO ACTION
  96.     ON UPDATE NO ACTION)
  97. ENGINE = InnoDB;
  98.  
  99.  
  100. -- -----------------------------------------------------
  101. -- Table `mydb`.`AJPitanja`
  102. -- -----------------------------------------------------
  103. CREATE TABLE IF NOT EXISTS `mydb`.`AJPitanja` (
  104.   `idPitanja` INT NOT NULL,
  105.   `pitanje` VARCHAR(40) NOT NULL,
  106.   `brojPoena` INT NOT NULL,
  107.   `AJTest_idSemaTest` INT NOT NULL,
  108.   PRIMARY KEY (`idPitanja`),
  109.   INDEX `fk_AJPitanja_AJTest1_idx` (`AJTest_idSemaTest` ASC),
  110.   CONSTRAINT `fk_AJPitanja_AJTest1`
  111.     FOREIGN KEY (`AJTest_idSemaTest`)
  112.     REFERENCES `mydb`.`AJTest` (`idSemaTest`)
  113.     ON DELETE NO ACTION
  114.     ON UPDATE NO ACTION)
  115. ENGINE = InnoDB;
  116.  
  117.  
  118. -- -----------------------------------------------------
  119. -- Table `mydb`.`AJUser`
  120. -- -----------------------------------------------------
  121. CREATE TABLE IF NOT EXISTS `mydb`.`AJUser` (
  122.   `idUser` INT GENERATED ALWAYS AS () VIRTUAL,
  123.   `username` VARCHAR(20) NOT NULL,
  124.   `password` VARCHAR(45) NOT NULL,
  125.   `uloga` VARCHAR(1) NOT NULL,
  126.   PRIMARY KEY (`idUser`))
  127. ENGINE = InnoDB;
  128.  
  129.  
  130. -- -----------------------------------------------------
  131. -- Table `mydb`.`AJRole`
  132. -- -----------------------------------------------------
  133. CREATE TABLE IF NOT EXISTS `mydb`.`AJRole` (
  134.   `idRole` INT GENERATED ALWAYS AS () VIRTUAL,
  135.   `Naziv` VARCHAR(20) NOT NULL,
  136.   PRIMARY KEY (`idRole`))
  137. ENGINE = InnoDB;
  138.  
  139.  
  140. -- -----------------------------------------------------
  141. -- Table `mydb`.`Predmet_has_Student`
  142. -- -----------------------------------------------------
  143. CREATE TABLE IF NOT EXISTS `mydb`.`Predmet_has_Student` (
  144.   `Predmet_idPredmet` INT NOT NULL,
  145.   `Student_idStudent` INT NOT NULL,
  146.   PRIMARY KEY (`Predmet_idPredmet`, `Student_idStudent`),
  147.   INDEX `fk_Predmet_has_Student_Student1_idx` (`Student_idStudent` ASC),
  148.   INDEX `fk_Predmet_has_Student_Predmet_idx` (`Predmet_idPredmet` ASC),
  149.   CONSTRAINT `fk_Predmet_has_Student_Predmet`
  150.     FOREIGN KEY (`Predmet_idPredmet`)
  151.     REFERENCES `mydb`.`AJPredmet` (`idPredmet`)
  152.     ON DELETE NO ACTION
  153.     ON UPDATE NO ACTION,
  154.   CONSTRAINT `fk_Predmet_has_Student_Student1`
  155.     FOREIGN KEY (`Student_idStudent`)
  156.     REFERENCES `mydb`.`AJStudent` (`idStudent`)
  157.     ON DELETE NO ACTION
  158.     ON UPDATE NO ACTION)
  159. ENGINE = InnoDB;
  160.  
  161.  
  162. -- -----------------------------------------------------
  163. -- Table `mydb`.`AJStudent_has_Predmet`
  164. -- -----------------------------------------------------
  165. CREATE TABLE IF NOT EXISTS `mydb`.`AJStudent_has_Predmet` (
  166.   `Student_idStudent` INT NOT NULL,
  167.   `Predmet_idPredmet` INT NOT NULL,
  168.   PRIMARY KEY (`Student_idStudent`, `Predmet_idPredmet`),
  169.   INDEX `fk_Student_has_Predmet_Predmet1_idx` (`Predmet_idPredmet` ASC),
  170.   INDEX `fk_Student_has_Predmet_Student1_idx` (`Student_idStudent` ASC),
  171.   CONSTRAINT `fk_Student_has_Predmet_Student1`
  172.     FOREIGN KEY (`Student_idStudent`)
  173.     REFERENCES `mydb`.`AJStudent` (`idStudent`)
  174.     ON DELETE NO ACTION
  175.     ON UPDATE NO ACTION,
  176.   CONSTRAINT `fk_Student_has_Predmet_Predmet1`
  177.     FOREIGN KEY (`Predmet_idPredmet`)
  178.     REFERENCES `mydb`.`AJPredmet` (`idPredmet`)
  179.     ON DELETE NO ACTION
  180.     ON UPDATE NO ACTION)
  181. ENGINE = InnoDB;
  182.  
  183.  
  184. -- -----------------------------------------------------
  185. -- Table `mydb`.`AJUser_has_Role`
  186. -- -----------------------------------------------------
  187. CREATE TABLE IF NOT EXISTS `mydb`.`AJUser_has_Role` (
  188.   `User_idUser` INT NOT NULL,
  189.   `Role_idRole` INT NOT NULL,
  190.   PRIMARY KEY (`User_idUser`, `Role_idRole`),
  191.   INDEX `fk_User_has_Role_Role1_idx` (`Role_idRole` ASC),
  192.   INDEX `fk_User_has_Role_User1_idx` (`User_idUser` ASC),
  193.   CONSTRAINT `fk_User_has_Role_User1`
  194.     FOREIGN KEY (`User_idUser`)
  195.     REFERENCES `mydb`.`AJUser` (`idUser`)
  196.     ON DELETE NO ACTION
  197.     ON UPDATE NO ACTION,
  198.   CONSTRAINT `fk_User_has_Role_Role1`
  199.     FOREIGN KEY (`Role_idRole`)
  200.     REFERENCES `mydb`.`AJRole` (`idRole`)
  201.     ON DELETE NO ACTION
  202.     ON UPDATE NO ACTION)
  203. ENGINE = InnoDB;
  204.  
  205.  
  206. -- -----------------------------------------------------
  207. -- Table `mydb`.`AJObavestenje`
  208. -- -----------------------------------------------------
  209. CREATE TABLE IF NOT EXISTS `mydb`.`AJObavestenje` (
  210.   `idObavestenje` INT NOT NULL,
  211.   `tekst` VARCHAR(100) NOT NULL,
  212.   `datum` DATETIME NOT NULL,
  213.   `AJPredmet_idPredmet` INT NOT NULL,
  214.   PRIMARY KEY (`idObavestenje`),
  215.   INDEX `fk_Obavestenje_AJPredmet1_idx` (`AJPredmet_idPredmet` ASC),
  216.   CONSTRAINT `fk_Obavestenje_AJPredmet1`
  217.     FOREIGN KEY (`AJPredmet_idPredmet`)
  218.     REFERENCES `mydb`.`AJPredmet` (`idPredmet`)
  219.     ON DELETE NO ACTION
  220.     ON UPDATE NO ACTION)
  221. ENGINE = InnoDB;
  222.  
  223.  
  224. -- -----------------------------------------------------
  225. -- Table `mydb`.`AJOdgovor`
  226. -- -----------------------------------------------------
  227. CREATE TABLE IF NOT EXISTS `mydb`.`AJOdgovor` (
  228.   `idOdgovor` INT NOT NULL,
  229.   `odgovor` VARCHAR(45) NOT NULL,
  230.   `AJPitanja_idPitanja` INT NOT NULL,
  231.   `AJStudent_idStudent` INT NOT NULL,
  232.   `tacnost` INT NOT NULL DEFAULT 1,
  233.   `AJPredmet_idPredmet` INT NOT NULL,
  234.   PRIMARY KEY (`idOdgovor`),
  235.   INDEX `fk_AJOdgovor_AJPitanja1_idx` (`AJPitanja_idPitanja` ASC),
  236.   INDEX `fk_AJOdgovor_AJStudent1_idx` (`AJStudent_idStudent` ASC),
  237.   INDEX `fk_AJOdgovor_AJPredmet1_idx` (`AJPredmet_idPredmet` ASC),
  238.   CONSTRAINT `fk_AJOdgovor_AJPitanja1`
  239.     FOREIGN KEY (`AJPitanja_idPitanja`)
  240.     REFERENCES `mydb`.`AJPitanja` (`idPitanja`)
  241.     ON DELETE NO ACTION
  242.     ON UPDATE NO ACTION,
  243.   CONSTRAINT `fk_AJOdgovor_AJStudent1`
  244.     FOREIGN KEY (`AJStudent_idStudent`)
  245.     REFERENCES `mydb`.`AJStudent` (`idStudent`)
  246.     ON DELETE NO ACTION
  247.     ON UPDATE NO ACTION,
  248.   CONSTRAINT `fk_AJOdgovor_AJPredmet1`
  249.     FOREIGN KEY (`AJPredmet_idPredmet`)
  250.     REFERENCES `mydb`.`AJPredmet` (`idPredmet`)
  251.     ON DELETE NO ACTION
  252.     ON UPDATE NO ACTION)
  253. ENGINE = InnoDB;
  254.  
  255.  
  256. SET SQL_MODE=@OLD_SQL_MODE;
  257. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  258. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top