-- phpMyAdmin SQL Dump
-- version 4.6.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 13, 2017 at 11:10 AM
-- Server version: 5.7.14
-- PHP Version: 7.0.10

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

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

--
-- Table structure for table `akcija`
--

CREATE TABLE IF NOT EXISTS `akcija` (
  `IdAkc` int(11) NOT NULL AUTO_INCREMENT,
  `Naziv` varchar(145) DEFAULT NULL,
  PRIMARY KEY (`IdAkc`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `akcija`
--

INSERT INTO `akcija` (`IdAkc`, `Naziv`) VALUES
(1, 'Nedeljom od 18h do 21h 50% jeftinija hrana'),
(2, 'Subotom besplatno pice uz svaku picu'),
(3, 'Utorkom od 21h do 23h besplatan dezert uz svaki obrok'),
(4, 'Nedeljom besplatni deciji obroci');

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

--
-- Table structure for table `akcijepicerija`
--

CREATE TABLE IF NOT EXISTS `akcijepicerija` (
  `IdPic` int(11) NOT NULL,
  `IdAkc` int(11) NOT NULL,
  `Status` tinyint(1) DEFAULT NULL COMMENT '1 = odobreno, 0 = na čekanju',
  PRIMARY KEY (`IdPic`,`IdAkc`),
  KEY `akcija_indeks` (`IdAkc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `akcijepicerija`
--

INSERT INTO `akcijepicerija` (`IdPic`, `IdAkc`, `Status`) VALUES
(1, 1, 1),
(3, 3, 0);

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

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

CREATE TABLE IF NOT EXISTS `korisnik` (
  `IdKor` int(11) NOT NULL AUTO_INCREMENT,
  `Ime` varchar(45) DEFAULT NULL,
  `Prezime` varchar(45) DEFAULT NULL,
  `Username` varchar(45) DEFAULT NULL,
  `Password` varchar(45) DEFAULT NULL,
  `Tip` tinyint(1) DEFAULT NULL COMMENT '0 = menadžer, 1 = šef picerije',
  `IdPicerije` int(11) DEFAULT NULL COMMENT 'samo za šefove picerija',
  PRIMARY KEY (`IdKor`),
  KEY `IdPicerije` (`IdPicerije`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

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

INSERT INTO `korisnik` (`IdKor`, `Ime`, `Prezime`, `Username`, `Password`, `Tip`, `IdPicerije`) VALUES
(1, 'Marko', 'Maric', 'mare', 'mare123', 1, 1),
(2, 'Nikola', 'Petrovic', 'nikola', 'dzoni123', 1, 2),
(3, 'Srdjan', 'Nikolic', 'srle', 'srle123', 0, NULL),
(4, 'Jelena', 'Rankovic', 'jeca', 'jeca123', 1, 3);

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

--
-- Table structure for table `picerija`
--

CREATE TABLE IF NOT EXISTS `picerija` (
  `IdPic` int(11) NOT NULL AUTO_INCREMENT,
  `Grad` varchar(45) DEFAULT NULL,
  `Adresa` varchar(45) DEFAULT NULL,
  `Kapacitet` int(11) DEFAULT NULL,
  `Basta` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`IdPic`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `picerija`
--

INSERT INTO `picerija` (`IdPic`, `Grad`, `Adresa`, `Kapacitet`, `Basta`) VALUES
(1, 'Beograd', 'Nemanjina 12', 87, 0),
(2, 'Beograd', 'Cara Dusana 79', 120, 1),
(3, 'Novi Sad', 'Vidovdanska 30', 120, 1);

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

--
-- Table structure for table `promet`
--

CREATE TABLE IF NOT EXISTS `promet` (
  `IdPic` int(11) NOT NULL,
  `Datum` date NOT NULL,
  `Promet` float DEFAULT NULL,
  PRIMARY KEY (`IdPic`,`Datum`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `promet`
--

INSERT INTO `promet` (`IdPic`, `Datum`, `Promet`) VALUES
(1, '2017-10-05', 200000),
(1, '2017-10-10', 300000),
(1, '2017-10-15', 150000),
(1, '2017-10-20', 200000),
(2, '2017-10-05', 300000),
(2, '2017-10-10', 300000),
(2, '2017-10-15', 300000),
(2, '2017-10-20', 300000),
(3, '2017-10-05', 100000),
(3, '2017-10-10', 200000),
(3, '2017-10-15', 300000);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `akcijepicerija`
--
ALTER TABLE `akcijepicerija`
  ADD CONSTRAINT `akcija_indeks` FOREIGN KEY (`IdAkc`) REFERENCES `akcija` (`IdAkc`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `picerija_indeks` FOREIGN KEY (`IdPic`) REFERENCES `picerija` (`IdPic`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `korisnik`
--
ALTER TABLE `korisnik`
  ADD CONSTRAINT `idPicerije_indeks` FOREIGN KEY (`IdPicerije`) REFERENCES `picerija` (`IdPic`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `promet`
--
ALTER TABLE `promet`
  ADD CONSTRAINT `picerija_promet_indeks` FOREIGN KEY (`IdPic`) REFERENCES `picerija` (`IdPic`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!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 */;
