
-- -----------------------------------------------------
-- Table `Korisnik`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Korisnik` (
  `JMBG` CHAR(15) NOT NULL,
  `ime` VARCHAR(45) NULL,
  `prezime` VARCHAR(45) NULL,
  `drzava` VARCHAR(45) NULL,
  `email` VARCHAR(45) NULL,
  `lozinka` VARCHAR(45) NULL,
  PRIMARY KEY (`JMBG`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Radnik`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Radnik` (
  `JMBG` CHAR(15) NOT NULL,
  `Datum_zaposlenja` DATE NULL,
  `Datrum-isteka_ugovora` DATE NULL,
  PRIMARY KEY (`JMBG`),
  CONSTRAINT `fk_Radnik_Korisnik`
    FOREIGN KEY (`JMBG`)
    REFERENCES `Korisnik` (`JMBG`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Drzava`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Drzava` (
  `idDrzava` INT NOT NULL,
  `Naziv` VARCHAR(45) NULL,
  PRIMARY KEY (`idDrzava`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Neregistrovani`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Neregistrovani` (
  `Korisnik_JMBG` CHAR(15) NOT NULL,
  PRIMARY KEY (`Korisnik_JMBG`),
  CONSTRAINT `fk_Nezaposleni_Korisnik1`
    FOREIGN KEY (`Korisnik_JMBG`)
    REFERENCES `Korisnik` (`JMBG`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Kategorija_putno_osiguranje`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Kategorija_putno_osiguranje` (
  `idKategorija` INT NOT NULL,
  `naziv` VARCHAR(45) NULL,
  `opis` VARCHAR(200) NULL,
  `iznos` INT NULL,
  PRIMARY KEY (`idKategorija`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Putno_osiguranje`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Putno_osiguranje` (
  `Drzava_idDrzava` INT NOT NULL,
  `Kategorija_putno_osiguranje_idKategorija` INT NOT NULL,
  PRIMARY KEY (`Drzava_idDrzava`, `Kategorija_putno_osiguranje_idKategorija`),
  INDEX `fk_Putno_osigurane_Drzava1_idx` (`Drzava_idDrzava` ASC),
  INDEX `fk_Putno_osigurane_Kategorija_putno_osiguranje1_idx` (`Kategorija_putno_osiguranje_idKategorija` ASC),
  CONSTRAINT `fk_Putno_osigurane_Drzava1`
    FOREIGN KEY (`Drzava_idDrzava`)
    REFERENCES `Drzava` (`idDrzava`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Putno_osigurane_Kategorija_putno_osiguranje1`
    FOREIGN KEY (`Kategorija_putno_osiguranje_idKategorija`)
    REFERENCES `Kategorija_putno_osiguranje` (`idKategorija`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Polisa_putnog_osiguranja`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Polisa_putnog_osiguranja` (
  `datum_od` INT NULL,
  `datum_do` VARCHAR(45) NULL,
  `Korisnik_JMBG` CHAR(15) NOT NULL,
  `Drzava_idDrzava` INT NOT NULL,
  `Kategorija_putno_osiguranje_idKategorija` INT NOT NULL,
  `iznos` INT NULL,
  `placeno` TINYINT(2) NULL,
  PRIMARY KEY (`Korisnik_JMBG`, `Drzava_idDrzava`, `Kategorija_putno_osiguranje_idKategorija`),
  INDEX `fk_Polisa_putnog_osiguranja_Drzava1_idx` (`Drzava_idDrzava` ASC),
  INDEX `fk_Polisa_putnog_osiguranja_Kategorija_putno_osiguranje1_idx` (`Kategorija_putno_osiguranje_idKategorija` ASC),
  CONSTRAINT `fk_Polisa_putnog_osiguranja_Korisnik1`
    FOREIGN KEY (`Korisnik_JMBG`)
    REFERENCES `Korisnik` (`JMBG`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Polisa_putnog_osiguranja_Drzava1`
    FOREIGN KEY (`Drzava_idDrzava`)
    REFERENCES `Drzava` (`idDrzava`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Polisa_putnog_osiguranja_Kategorija_putno_osiguranje1`
    FOREIGN KEY (`Kategorija_putno_osiguranje_idKategorija`)
    REFERENCES `Kategorija_putno_osiguranje` (`idKategorija`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Kategorije_automobil_osiguranje`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Kategorije_automobil_osiguranje` (
  `idkategorije_automobil_osiguranje` INT NOT NULL,
  `naziv` VARCHAR(45) NULL,
  `opis` VARCHAR(200) NULL,
  `iznos` INT NULL,
  PRIMARY KEY (`idkategorije_automobil_osiguranje`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Polisa_automobil_osiguranje`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Polisa_automobil_osiguranje` (
  `Korisnik_JMBG` CHAR(15) NOT NULL,
  `godina` INT NULL,
  `iznos` INT NULL,
  `registarski_broj` CHAR(10) NULL,
  `placeno` TINYINT(2) NULL,
  `idkategorije_automobil_osiguranje` INT NOT NULL,
  PRIMARY KEY (`Korisnik_JMBG`),
  CONSTRAINT `fk_polisa_automobil_osiguranje_Korisnik1`
    FOREIGN KEY (`Korisnik_JMBG`)
    REFERENCES `Korisnik` (`JMBG`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Kategorije_automobil_osiguranje1`
    FOREIGN KEY (`idkategorije_automobil_osiguranje`)
    REFERENCES `Kategorije_automobil_osiguranje` (`idkategorije_automobil_osiguranje`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


