-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jan 29, 2021 at 11:17 PM
-- 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: `palacinkarnica2021`
--
DROP DATABASE IF EXISTS `palacinkarnica2021`;
CREATE DATABASE IF NOT EXISTS `palacinkarnica2021` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE `palacinkarnica2021`;

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

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

DROP TABLE IF EXISTS `dodaci`;
CREATE TABLE IF NOT EXISTS `dodaci` (
  `idD` int NOT NULL,
  `naziv` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`idD`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `dodaci` (`idD`, `naziv`) VALUES
(1, 'nutela'),
(2, 'visnja'),
(3, 'banana'),
(4, 'plazma'),
(5, 'kokos'),
(6, 'coko mrvice'),
(7, 'dzem'),
(8, 'sunka'),
(9, 'prsuta');

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

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

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `ime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `prezime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `kor_ime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `lozinka` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `tip` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`kor_ime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `korisnici` (`ime`, `prezime`, `kor_ime`, `lozinka`, `tip`) VALUES
('Ana', 'Jokic', 'ana', 'ana123', 'radnik'),
('Ivan', 'Lazic', 'ivan', 'ivan123', 'radnik'),
('Jovana', 'Matic', 'joca', 'joca123', 'kupac'),
('Marko', 'Lukic', 'mare', 'mare123', 'kupac');

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

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

DROP TABLE IF EXISTS `narudzbine`;
CREATE TABLE IF NOT EXISTS `narudzbine` (
  `idN` int NOT NULL AUTO_INCREMENT,
  `proizvod` int DEFAULT NULL,
  `kupac` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `datum` date DEFAULT NULL,
  `status` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`idN`),
  KEY `proizvodi_idx` (`proizvod`),
  KEY `kupac` (`kupac`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `narudzbine` (`idN`, `proizvod`, `kupac`, `datum`, `status`) VALUES
(1, 1, 'joca', '2020-01-28', 'Prihvaceno'),
(2, 2, 'mare', '2020-01-24', 'Neobradjeno');

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

--
-- Table structure for table `narudzbine_dodaci`
--

DROP TABLE IF EXISTS `narudzbine_dodaci`;
CREATE TABLE IF NOT EXISTS `narudzbine_dodaci` (
  `idN` int NOT NULL,
  `idD` int NOT NULL,
  PRIMARY KEY (`idN`,`idD`),
  KEY `dodaci_idx` (`idD`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `narudzbine_dodaci`
--

INSERT INTO `narudzbine_dodaci` (`idN`, `idD`) VALUES
(1, 1),
(1, 2),
(2, 8);

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

--
-- Table structure for table `proizvodi`
--

DROP TABLE IF EXISTS `proizvodi`;
CREATE TABLE IF NOT EXISTS `proizvodi` (
  `idP` int NOT NULL,
  `naziv` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`idP`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `proizvodi`
--

INSERT INTO `proizvodi` (`idP`, `naziv`) VALUES
(1, 'slatka palacinka'),
(2, 'slana palacinka'),
(3, 'vafl'),
(4, 'krofna');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `narudzbine`
--
ALTER TABLE `narudzbine`
  ADD CONSTRAINT `narudzbine_ibfk_1` FOREIGN KEY (`kupac`) REFERENCES `korisnici` (`kor_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `proizvodi` FOREIGN KEY (`proizvod`) REFERENCES `proizvodi` (`idP`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `narudzbine_dodaci`
--
ALTER TABLE `narudzbine_dodaci`
  ADD CONSTRAINT `dodaci` FOREIGN KEY (`idD`) REFERENCES `dodaci` (`idD`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `narudzbine_dodaci_ibfk_1` FOREIGN KEY (`idN`) REFERENCES `narudzbine` (`idN`) 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 */;
