-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jun 10, 2019 at 12:13 PM
-- Server version: 5.7.19
-- PHP Version: 7.1.9

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `nasbioskop2019`
--
CREATE DATABASE IF NOT EXISTS `nasbioskop2019` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `nasbioskop2019`;

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

--
-- Table structure for table `filmovi`
--

DROP TABLE IF EXISTS `filmovi`;
CREATE TABLE IF NOT EXISTS `filmovi` (
  `idFilm` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `zemlja` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `godina` int(11) NOT NULL,
  PRIMARY KEY (`idFilm`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `filmovi`
--

INSERT INTO `filmovi` (`idFilm`, `naziv`, `zemlja`, `godina`) VALUES
(1, 'Aladin', 'SAD', 2019),
(2, 'Patuljci sa naslovnih strana', 'Srbija', 2018),
(3, 'Druga strana svega', 'Srbija', 2018),
(4, 'Stranac', 'SAD', 2018);

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

--
-- Table structure for table `korisnici`
--

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `korisnickoime` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `lozinka` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `zanimanje` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `tip` tinyint(4) NOT NULL COMMENT '1 - posetilac, 2 - blagajnik',
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnici`
--

INSERT INTO `korisnici` (`korisnickoime`, `lozinka`, `ime`, `prezime`, `zanimanje`, `tip`) VALUES
('blagajna', 'cineplex123', 'Misa', 'Milosevic', 'blagajnik', 2),
('blagajna2', 'cineplex123', 'Rada', 'Radenkovic', 'blagajnica', 2),
('bosko', 'sifra123', 'Bosko', 'Nikolic', 'profesor', 1),
('laza', 'sifra123456', 'Laza', 'Lazic', 'ekonomista', 1),
('marija', 'sifra1234', 'Marina', 'Marinkovic', 'apotekar', 1),
('nikola', 'sifra12345', 'Nikola', 'Nikolic', 'pijanista', 1);

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

--
-- Table structure for table `pripadazanru`
--

DROP TABLE IF EXISTS `pripadazanru`;
CREATE TABLE IF NOT EXISTS `pripadazanru` (
  `idFilma` int(11) NOT NULL,
  `idZanra` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idFilma`,`idZanra`),
  KEY `fk_idZanra` (`idZanra`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `pripadazanru`
--

INSERT INTO `pripadazanru` (`idFilma`, `idZanra`) VALUES
(4, 'akcioni'),
(1, 'avantura'),
(3, 'dokumentarni'),
(1, 'komedija'),
(2, 'komedija'),
(4, 'triler');

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

--
-- Table structure for table `projekcija`
--

DROP TABLE IF EXISTS `projekcija`;
CREATE TABLE IF NOT EXISTS `projekcija` (
  `idProjekcija` int(11) NOT NULL AUTO_INCREMENT,
  `idFilm` int(11) NOT NULL,
  `datum` date NOT NULL,
  `vreme` int(11) NOT NULL,
  `sala` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idProjekcija`),
  KEY `idFilm` (`idFilm`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `projekcija`
--

INSERT INTO `projekcija` (`idProjekcija`, `idFilm`, `datum`, `vreme`, `sala`) VALUES
(1, 2, '2019-06-15', 18, 'A'),
(2, 1, '2019-06-16', 20, 'A'),
(3, 1, '2019-06-16', 22, 'A'),
(4, 3, '2019-06-16', 20, 'B'),
(5, 3, '2019-06-17', 20, 'A');

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

--
-- Table structure for table `rezervacija`
--

DROP TABLE IF EXISTS `rezervacija`;
CREATE TABLE IF NOT EXISTS `rezervacija` (
  `idRezeravacije` int(11) NOT NULL AUTO_INCREMENT,
  `idProjekcije` int(11) NOT NULL,
  `korisnickoIme` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `brojUlaznica` int(11) NOT NULL DEFAULT '2',
  PRIMARY KEY (`idRezeravacije`),
  KEY `fk_idProjekcije` (`idProjekcije`),
  KEY `fk_idKorisnik` (`korisnickoIme`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `rezervacija`
--

INSERT INTO `rezervacija` (`idRezeravacije`, `idProjekcije`, `korisnickoIme`, `brojUlaznica`) VALUES
(1, 1, 'bosko', 2),
(2, 2, 'laza', 2);

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

--
-- Table structure for table `zanr`
--

DROP TABLE IF EXISTS `zanr`;
CREATE TABLE IF NOT EXISTS `zanr` (
  `nazivZanra` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`nazivZanra`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `zanr`
--

INSERT INTO `zanr` (`nazivZanra`) VALUES
('akcioni'),
('avantura'),
('dokumentarni'),
('drama'),
('komedija'),
('triler');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `pripadazanru`
--
ALTER TABLE `pripadazanru`
  ADD CONSTRAINT `fk_idFilma` FOREIGN KEY (`idFilma`) REFERENCES `filmovi` (`idFilm`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_idZanra` FOREIGN KEY (`idZanra`) REFERENCES `zanr` (`nazivZanra`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `projekcija`
--
ALTER TABLE `projekcija`
  ADD CONSTRAINT `fk_idFilm` FOREIGN KEY (`idFilm`) REFERENCES `filmovi` (`idFilm`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rezervacija`
--
ALTER TABLE `rezervacija`
  ADD CONSTRAINT `fk_idKorisnik` FOREIGN KEY (`korisnickoIme`) REFERENCES `korisnici` (`korisnickoime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_idProjekcije` FOREIGN KEY (`idProjekcije`) REFERENCES `projekcija` (`idProjekcija`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
