-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: May 07, 2021 at 10:55 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: `prodavnica2021`
--
DROP DATABASE IF EXISTS `prodavnica2021`;
CREATE DATABASE IF NOT EXISTS `prodavnica2021` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `prodavnica2021`;

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

--
-- 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 NOT NULL,
  `prezime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `korisnicko_ime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `lozinka` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `tip` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`korisnicko_ime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `korisnici` (`ime`, `prezime`, `korisnicko_ime`, `lozinka`, `tip`) VALUES
('Anica', 'Petrovic', 'anicica', 'anica123', 'radnik'),
('Jova', 'Zivkovic', 'jovica', 'jova123', 'radnik'),
('Milica', 'Stojic', 'milicica', 'mica123', 'kupac'),
('Mirko', 'Jovanovic', 'mirkoni', 'mirko123', 'kupac');

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

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

DROP TABLE IF EXISTS `narudzbine`;
CREATE TABLE IF NOT EXISTS `narudzbine` (
  `idN` int NOT NULL AUTO_INCREMENT,
  `idP` int NOT NULL,
  `korisnicko_ime` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `status` int NOT NULL DEFAULT '1',
  PRIMARY KEY (`idN`),
  KEY `proizvodi` (`idP`),
  KEY `korisnici` (`korisnicko_ime`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `narudzbine` (`idN`, `idP`, `korisnicko_ime`, `status`) VALUES
(1, 1, 'milicica', 1),
(2, 2, 'milicica', 2),
(3, 3, 'mirkoni', 1),
(4, 4, 'mirkoni', 3);

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

--
-- 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) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `cena` int NOT NULL,
  `kolicina` int NOT NULL,
  PRIMARY KEY (`idP`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

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

INSERT INTO `proizvodi` (`idP`, `naziv`, `cena`, `kolicina`) VALUES
(1, 'Hleb', 100, 10),
(2, 'Cokolada', 250, 3),
(3, 'Brasno', 50, 5),
(4, 'Secer', 50, 0);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `narudzbine`
--
ALTER TABLE `narudzbine`
  ADD CONSTRAINT `korisnici` FOREIGN KEY (`korisnicko_ime`) REFERENCES `korisnici` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `proizvodi` FOREIGN KEY (`idP`) 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 */;
