-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jul 10, 2021 at 10:04 AM
-- Server version: 8.0.21
-- PHP Version: 7.3.21

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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: `autoskola2021`
--
DROP DATABASE IF EXISTS `autoskola2021`;
CREATE DATABASE IF NOT EXISTS `autoskola2021` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `autoskola2021`;

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

--
-- 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,
  `datumRodjenja` date NOT NULL,
  `mesto` int NOT NULL,
  `jeInspektor` tinyint(1) NOT NULL,
  PRIMARY KEY (`username`),
  KEY `mesto` (`mesto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

INSERT INTO `korisnik` (`username`, `password`, `ime`, `prezime`, `datumRodjenja`, `mesto`, `jeInspektor`) VALUES
('aleksa', 'aleksa123', 'Aleksa', 'Aleksić', '1970-01-01', 14000, 1),
('bob', 'bob123', 'Slobodan', 'Inspektoric', '1965-06-06', 11000, 1),
('bosa', 'bosa123', 'Bosa', 'Bosiljčić', '1991-05-25', 11000, 0),
('djura', 'djura123', 'Djura', 'Djuric', '2003-07-10', 11300, 0),
('jeca', 'jeca123', 'Jeca', 'Cincović', '2003-04-16', 11000, 0),
('mica', 'mica123', 'Milovan', 'Milovanović', '2000-10-09', 21000, 0),
('pera', 'pera123', 'Petar', 'Mladić', '2005-05-05', 11000, 0),
('sanja', 'sanja123', 'Sanja', 'Sanjić', '1993-04-10', 11000, 0),
('zika', 'zika123', 'Živojin', 'Mišić', '1995-08-08', 14000, 0);

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

--
-- Table structure for table `mesto`
--

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

--
-- Dumping data for table `mesto`
--

INSERT INTO `mesto` (`idMesto`, `naziv`) VALUES
(11000, 'Beograd'),
(11300, 'Smederevo'),
(14000, 'Valjevo'),
(15000, 'Šabac'),
(21000, 'Novi Sad'),
(34000, 'Kragujevac');

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

--
-- Table structure for table `polaganje`
--

DROP TABLE IF EXISTS `polaganje`;
CREATE TABLE IF NOT EXISTS `polaganje` (
  `idPolaganja` int NOT NULL AUTO_INCREMENT,
  `idPrijave` int NOT NULL,
  `brojPoena` int DEFAULT NULL,
  `datum` date NOT NULL,
  `polozio` tinyint NOT NULL,
  `inspektor` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idPolaganja`),
  KEY `inspektor` (`inspektor`),
  KEY `idPrijave` (`idPrijave`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `polaganje`
--

INSERT INTO `polaganje` (`idPolaganja`, `idPrijave`, `brojPoena`, `datum`, `polozio`, `inspektor`) VALUES
(1, 1, 39, '2021-06-28', 0, 'bob'),
(2, 2, 98, '2021-06-28', 1, 'bob'),
(3, 6, NULL, '2021-07-08', 1, 'bob'),
(4, 4, 77, '2021-06-01', 0, 'aleksa'),
(5, 7, 96, '2021-07-01', 1, 'bob');

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

--
-- Table structure for table `prijava`
--

DROP TABLE IF EXISTS `prijava`;
CREATE TABLE IF NOT EXISTS `prijava` (
  `idPrijava` int NOT NULL AUTO_INCREMENT,
  `vrstaPolaganja` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `mesto` int NOT NULL,
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `status` tinyint(1) NOT NULL,
  PRIMARY KEY (`idPrijava`),
  KEY `mesto` (`mesto`),
  KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `prijava`
--

INSERT INTO `prijava` (`idPrijava`, `vrstaPolaganja`, `mesto`, `username`, `status`) VALUES
(1, 't', 11000, 'bosa', 0),
(2, 't', 11000, 'sanja', 1),
(4, 't', 14000, 'djura', 0),
(5, 't', 11000, 'djura', 1),
(6, 'v', 11000, 'sanja', 1),
(7, 't', 11000, 'mica', 1),
(8, 'v', 11000, 'mica', 1);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `korisnik`
--
ALTER TABLE `korisnik`
  ADD CONSTRAINT `korisnik_ibfk_1` FOREIGN KEY (`mesto`) REFERENCES `mesto` (`idMesto`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `polaganje`
--
ALTER TABLE `polaganje`
  ADD CONSTRAINT `polaganje_ibfk_1` FOREIGN KEY (`idPrijave`) REFERENCES `prijava` (`idPrijava`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `polaganje_ibfk_2` FOREIGN KEY (`inspektor`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `prijava`
--
ALTER TABLE `prijava`
  ADD CONSTRAINT `prijava_ibfk_1` FOREIGN KEY (`mesto`) REFERENCES `mesto` (`idMesto`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `prijava_ibfk_2` FOREIGN KEY (`username`) REFERENCES `korisnik` (`username`) 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 */;
