-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Nov 27, 2020 at 08:48 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: `radnja2020`
--
DROP DATABASE IF EXISTS `radnja2020`;
CREATE DATABASE IF NOT EXISTS `radnja2020` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `radnja2020`;

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

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

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

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

INSERT INTO `korisnici` (`ime`, `prezime`, `kor_ime`, `lozinka`, `tip`) VALUES
('Jova', 'Maric', 'jova', 'jova123', 'kupac'),
('Lazar', 'Jovic', 'laza', 'laza123', 'kupac'),
('Mina', 'Savic', 'mina', 'mina123', 'prodavac'),
('Mirko', 'Nikolic', 'mirko', 'mirko123', 'kupac'),
('Sava', 'Lukic', 'sava', 'sava123', 'prodavac');

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

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

DROP TABLE IF EXISTS `narudzbine`;
CREATE TABLE IF NOT EXISTS `narudzbine` (
  `idN` int NOT NULL AUTO_INCREMENT,
  `kupac` varchar(45) DEFAULT NULL,
  `proizvod` int DEFAULT NULL,
  `kolicina` int DEFAULT NULL,
  PRIMARY KEY (`idN`),
  KEY `kupac` (`kupac`),
  KEY `proizvod` (`proizvod`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

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

INSERT INTO `narudzbine` (`idN`, `kupac`, `proizvod`, `kolicina`) VALUES
(1, 'jova', 1, 5),
(2, 'jova', 2, 2),
(3, 'mirko', 2, 2);

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

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

DROP TABLE IF EXISTS `proizvodi`;
CREATE TABLE IF NOT EXISTS `proizvodi` (
  `idP` int NOT NULL AUTO_INCREMENT,
  `naziv` varchar(45) DEFAULT NULL,
  `cena` varchar(45) DEFAULT NULL,
  `kolicina` int DEFAULT NULL,
  PRIMARY KEY (`idP`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

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

INSERT INTO `proizvodi` (`idP`, `naziv`, `cena`, `kolicina`) VALUES
(1, 'cokolada', '200', 10),
(2, 'hleb', '60', 3),
(3, 'kafa', '180', 6),
(4, 'sok', '50', 1);

--
-- 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 `narudzbine_ibfk_2` FOREIGN KEY (`proizvod`) REFERENCES `proizvodi` (`idP`) 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 */;
