-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: May 11, 2018 at 07:11 PM
-- Server version: 5.7.19
-- PHP Version: 5.6.31

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: `e-menjaza2018`
--
CREATE DATABASE IF NOT EXISTS `e-menjaza2018` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `e-menjaza2018`;

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

--
-- Table structure for table `duplikati`
--

DROP TABLE IF EXISTS `duplikati`;
CREATE TABLE IF NOT EXISTS `duplikati` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `idSlicice` int(11) NOT NULL,
  PRIMARY KEY (`username`,`idSlicice`),
  KEY `fk_DuplikatId` (`idSlicice`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `duplikati`
--

INSERT INTO `duplikati` (`username`, `idSlicice`) VALUES
('drasko', 13),
('sanja', 21),
('sanja', 34),
('drasko', 35);

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

--
-- Table structure for table `korisnik`
--

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `tipKorisnika` tinyint(4) NOT NULL COMMENT '0 - obican, 1 - administrator',
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnik`
--

INSERT INTO `korisnik` (`username`, `password`, `ime`, `prezime`, `tipKorisnika`) VALUES
('drasko', 'sifra123', 'Dražen', 'Drašković', 0),
('jelica', 'sifra123', 'Jelica', 'Cincović', 0),
('milo', 'sifra123', 'Milo', 'Tomašević', 0),
('nbosko', 'admin123', 'Boško', 'Nikolić', 1),
('sanja', 'sifra123', 'Sanja', 'Delčev', 0);

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

--
-- Table structure for table `moj_album`
--

DROP TABLE IF EXISTS `moj_album`;
CREATE TABLE IF NOT EXISTS `moj_album` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `idSlicice` int(11) NOT NULL,
  PRIMARY KEY (`username`,`idSlicice`),
  KEY `fkIdSlicice` (`idSlicice`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `moj_album`
--

INSERT INTO `moj_album` (`username`, `idSlicice`) VALUES
('milo', 1),
('drasko', 2),
('sanja', 3),
('milo', 10),
('sanja', 10),
('sanja', 11),
('drasko', 13),
('milo', 18),
('drasko', 20),
('sanja', 21),
('milo', 24),
('drasko', 25),
('sanja', 31),
('drasko', 32),
('sanja', 34),
('drasko', 35),
('milo', 39),
('drasko', 42),
('drasko', 44),
('sanja', 44),
('sanja', 48);

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

--
-- Table structure for table `otvorio_kesicu`
--

DROP TABLE IF EXISTS `otvorio_kesicu`;
CREATE TABLE IF NOT EXISTS `otvorio_kesicu` (
  `idOtvaranja` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `datum` date NOT NULL,
  PRIMARY KEY (`idOtvaranja`),
  KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `otvorio_kesicu`
--

INSERT INTO `otvorio_kesicu` (`idOtvaranja`, `username`, `datum`) VALUES
(1, 'milo', '2018-05-11'),
(2, 'drasko', '2018-05-11'),
(3, 'sanja', '2018-05-12'),
(4, 'drasko', '2018-05-12'),
(5, 'sanja', '2018-05-12');

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

--
-- Table structure for table `slicica`
--

DROP TABLE IF EXISTS `slicica`;
CREATE TABLE IF NOT EXISTS `slicica` (
  `idSlicice` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `zemlja` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
  `tip` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idSlicice`),
  KEY `tip` (`tip`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `slicica`
--

INSERT INTO `slicica` (`idSlicice`, `naziv`, `zemlja`, `tip`) VALUES
(1, 'Official Ball', NULL, 'FIFA uvodna'),
(2, 'FIFA World Cup Trophy', NULL, 'FIFA uvodna'),
(3, 'FIFA Fair Play', NULL, 'FIFA uvodna'),
(4, 'Zabivaka the Mascot', NULL, 'FIFA uvodna'),
(5, 'Luzhniki Stadium', NULL, 'stadioni'),
(6, 'Saint Petersburg Stadium', NULL, 'stadioni'),
(7, 'Fisht Stadium Sochi', NULL, 'stadioni'),
(8, 'Ekaterinburg Arena', NULL, 'stadioni'),
(9, 'Kazan Arena', NULL, 'stadioni'),
(10, 'Russia Emblem', 'RUS', 'grb'),
(11, 'Igor Akinfeev', 'RUS', 'igrač'),
(12, 'Igor Smolnikov', 'RUS', 'igrač'),
(13, 'Denis Glushakov', 'RUS', 'igrač'),
(14, 'Fedor Smolov', 'RUS', 'igrač'),
(15, 'Aleksandr Kokorin', 'RUS', 'igrač'),
(16, 'Spain Emblem', 'ESP', 'grb'),
(17, 'David De Gea', 'ESP', 'igrač'),
(18, 'Gerard Pique', 'ESP', 'igrač'),
(19, 'Sergio Ramos', 'ESP', 'igrač'),
(20, 'Isco', 'ESP', 'igrač'),
(21, 'Alvaro Morata', 'ESP', 'igrač'),
(22, 'France Emblem', 'FRA', 'grb'),
(23, 'Hugo Lloris', 'FRA', 'igrač'),
(24, 'Raphael Varane', 'FRA', 'igrač'),
(25, 'Paul Pogba', 'FRA', 'igrač'),
(26, 'Antoine Griezmann', 'FRA', 'igrač'),
(27, 'Kylian Mbappe', 'FRA', 'igrač'),
(28, 'Argentina Emblem', 'ARG', 'grb'),
(29, 'Sergio Romero', 'ARG', 'grb'),
(30, 'Javier Mascherano', 'ARG', 'igrač'),
(31, 'Angel Di Maria', 'ARG', 'igrač'),
(32, 'Lionel Messi', 'ARG', 'igrač'),
(33, 'Sergio Aguero', 'ARG', 'igrač'),
(34, 'Brasil Emblem', 'BRA', 'grb'),
(35, 'Allison', 'BRA', 'igrač'),
(36, 'Dani Alves', 'BRA', 'igrač'),
(37, 'Marcelo', 'BRA', 'igrač'),
(38, 'Philippe Coutinho', 'BRA', 'igrač'),
(39, 'Neymar Junior', 'BRA', 'igrač'),
(40, 'Serbia Emblem', 'SRB', 'grb'),
(41, 'Vladimir Stojkovic', 'SRB', 'igrač'),
(42, 'Branislav Ivanovic', 'SRB', 'igrač'),
(43, 'Aleksandar Kolarov', 'SRB', 'igrač'),
(44, 'Nemanja Matic', 'SRB', 'igrač'),
(45, 'Aleksandar Mitrovic', 'SRB', 'igrač'),
(46, 'Uruguay 1930', NULL, 'istorijat zvezdi SP'),
(47, 'England 1966', NULL, 'istorijat zvezdi SP'),
(48, 'Argentina 1978 1986', NULL, 'istorijat zvezdi SP'),
(49, 'Germany 1990 2014', NULL, 'istorijat zvezdi SP'),
(50, 'Brasil 1994 2002', 'BRA', 'istorijat zvezdi SP');

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

--
-- Table structure for table `tip_slicice`
--

DROP TABLE IF EXISTS `tip_slicice`;
CREATE TABLE IF NOT EXISTS `tip_slicice` (
  `tipNaziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`tipNaziv`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `tip_slicice`
--

INSERT INTO `tip_slicice` (`tipNaziv`) VALUES
('FIFA uvodna'),
('grb'),
('igrač'),
('istorijat zvezdi SP'),
('stadioni');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `duplikati`
--
ALTER TABLE `duplikati`
  ADD CONSTRAINT `fk_DuplikatId` FOREIGN KEY (`idSlicice`) REFERENCES `slicica` (`idSlicice`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_DuplikatUsername` FOREIGN KEY (`username`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `moj_album`
--
ALTER TABLE `moj_album`
  ADD CONSTRAINT `fkIdSlicice` FOREIGN KEY (`idSlicice`) REFERENCES `slicica` (`idSlicice`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fkUsername` FOREIGN KEY (`username`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `otvorio_kesicu`
--
ALTER TABLE `otvorio_kesicu`
  ADD CONSTRAINT `fk_OtvorioUsername` FOREIGN KEY (`username`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `slicica`
--
ALTER TABLE `slicica`
  ADD CONSTRAINT `slicica_ibfk_1` FOREIGN KEY (`tip`) REFERENCES `tip_slicice` (`tipNaziv`) ON DELETE CASCADE ON UPDATE NO ACTION;
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 */;
