-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jan 09, 2020 at 01:13 AM
-- 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: `kafeterija2020`
--
CREATE DATABASE IF NOT EXISTS `kafeterija2020` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `kafeterija2020`;

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

--
-- Table structure for table `dodaci`
--

DROP TABLE IF EXISTS `dodaci`;
CREATE TABLE IF NOT EXISTS `dodaci` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(50) NOT NULL,
  `cena` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `dodaci`
--

INSERT INTO `dodaci` (`id`, `naziv`, `cena`) VALUES
(1, 'bademovo mleko', 50),
(2, 'sojino mleko', 35),
(3, 'kugla sladoleda', 50),
(4, 'sirup lesnik', 40),
(5, 'sirup karamela', 40),
(6, 'sirup menta', 40);

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

--
-- Table structure for table `kafe`
--

DROP TABLE IF EXISTS `kafe`;
CREATE TABLE IF NOT EXISTS `kafe` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(50) NOT NULL,
  `cena_s` int(11) NOT NULL,
  `cena_m` int(11) NOT NULL,
  `cena_l` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `kafe`
--

INSERT INTO `kafe` (`id`, `naziv`, `cena_s`, `cena_m`, `cena_l`) VALUES
(1, 'espreso', 100, 130, 150),
(2, 'makijato', 110, 135, 160),
(3, 'kapucino', 150, 170, 190),
(4, 'late', 170, 190, 215),
(5, 'moka', 190, 215, 230);

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

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

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `korime` varchar(50) NOT NULL,
  `lozinka` varchar(50) NOT NULL,
  `ime` varchar(50) NOT NULL,
  `prezime` varchar(50) NOT NULL,
  `tip` varchar(10) NOT NULL,
  PRIMARY KEY (`korime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

INSERT INTO `korisnici` (`korime`, `lozinka`, `ime`, `prezime`, `tip`) VALUES
('bosko', 'bosko123', 'Bosko', 'Boskovic', 'admin'),
('drazen', 'drazen123', 'Drazen', 'Drazic', 'kupac'),
('jelica', 'jelica123', 'Jelica', 'Jelicic', 'kupac'),
('mica', 'mica123', 'Mica', 'Micic', 'kupac'),
('sanja', 'sanja123', 'Sanja', 'Sanjic', 'kupac');

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

--
-- Table structure for table `narudzbine`
--

DROP TABLE IF EXISTS `narudzbine`;
CREATE TABLE IF NOT EXISTS `narudzbine` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `aktivna` tinyint(1) NOT NULL,
  `narucio` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `narucio` (`narucio`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `narudzbine`
--

INSERT INTO `narudzbine` (`id`, `aktivna`, `narucio`) VALUES
(1, 0, 'sanja'),
(2, 1, 'sanja'),
(3, 1, 'mica');

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

--
-- Table structure for table `stavke`
--

DROP TABLE IF EXISTS `stavke`;
CREATE TABLE IF NOT EXISTS `stavke` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_kafe` int(11) NOT NULL,
  `velicina` char(1) NOT NULL,
  `dodaci` varchar(50) DEFAULT NULL,
  `cena` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_kafe` (`id_kafe`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `stavke`
--

INSERT INTO `stavke` (`id`, `id_kafe`, `velicina`, `dodaci`, `cena`) VALUES
(1, 1, 'm', NULL, 130),
(2, 1, 's', '3', 150),
(3, 1, 'l', NULL, 150),
(4, 4, 'm', '1,4', 280),
(5, 5, 'm', '1,6', 305),
(6, 1, 'l', NULL, 150);

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

--
-- Table structure for table `stavke_narudzbine`
--

DROP TABLE IF EXISTS `stavke_narudzbine`;
CREATE TABLE IF NOT EXISTS `stavke_narudzbine` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_narudzbine` int(11) NOT NULL,
  `id_stavke` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_narudzbine` (`id_narudzbine`),
  KEY `id_stavke` (`id_stavke`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `stavke_narudzbine`
--

INSERT INTO `stavke_narudzbine` (`id`, `id_narudzbine`, `id_stavke`) VALUES
(1, 1, 1),
(2, 2, 2),
(3, 2, 3),
(4, 2, 4),
(5, 2, 5),
(6, 3, 6);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `narudzbine`
--
ALTER TABLE `narudzbine`
  ADD CONSTRAINT `fk_narucio` FOREIGN KEY (`narucio`) REFERENCES `korisnici` (`korime`);

--
-- Constraints for table `stavke`
--
ALTER TABLE `stavke`
  ADD CONSTRAINT `fk_stavka_kafa` FOREIGN KEY (`id_kafe`) REFERENCES `kafe` (`id`);

--
-- Constraints for table `stavke_narudzbine`
--
ALTER TABLE `stavke_narudzbine`
  ADD CONSTRAINT `fk_narudzbina` FOREIGN KEY (`id_narudzbine`) REFERENCES `narudzbine` (`id`),
  ADD CONSTRAINT `fk_stavka` FOREIGN KEY (`id_stavke`) REFERENCES `stavke` (`id`);
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 */;
