-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Aug 23, 2025 at 01:09 PM
-- Server version: 8.2.0
-- PHP Version: 8.2.13

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: `oprema2025`
--
CREATE DATABASE IF NOT EXISTS `oprema2025` DEFAULT CHARACTER SET utf16 COLLATE utf16_bin;
USE `oprema2025`;

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

--
-- Table structure for table `komentari`
--

DROP TABLE IF EXISTS `komentari`;
CREATE TABLE IF NOT EXISTS `komentari` (
  `idK` int NOT NULL AUTO_INCREMENT,
  `proizvod` int NOT NULL,
  `tekst` varchar(45) COLLATE utf16_bin NOT NULL,
  `korisnik` varchar(45) COLLATE utf16_bin NOT NULL,
  `status` varchar(45) COLLATE utf16_bin NOT NULL,
  PRIMARY KEY (`idK`),
  KEY `proizvod` (`proizvod`),
  KEY `korisnik` (`korisnik`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

--
-- Dumping data for table `komentari`
--

INSERT INTO `komentari` (`idK`, `proizvod`, `tekst`, `korisnik`, `status`) VALUES
(1, 1, 'Ovo je bas super lopta. Igram se svaki dan.', 'pera', 'odobren'),
(2, 1, 'Ok je', 'ana', 'odobren'),
(3, 2, 'Odlican odnos cena kvalitet', 'ana', 'odobren'),
(4, 2, 'Nista specijalno', 'pera', 'neodobren');

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

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

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

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

INSERT INTO `korisnici` (`kor_ime`, `lozinka`, `ime`, `prezime`, `mejl`, `tip`) VALUES
('ana', 'ana123', 'Ana', 'Ivanovic', 'ana@gmail.com', 'kupac'),
('jova', 'jova123', 'Jova', 'Matic', 'jova@gmail.com', 'radnik'),
('pera', 'pera123', 'Petar', 'Petrovic', 'pera@gmail.com', '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 NOT NULL,
  `kolicina` int NOT NULL,
  `kupac` varchar(45) COLLATE utf16_bin NOT NULL,
  PRIMARY KEY (`idN`),
  KEY `kupac` (`kupac`),
  KEY `proizvod` (`proizvod`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

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

INSERT INTO `narudzbine` (`idN`, `proizvod`, `kolicina`, `kupac`) VALUES
(1, 1, 1, 'pera'),
(2, 1, 1, 'pera'),
(3, 2, 1, 'ana'),
(4, 2, 1, 'pera'),
(5, 1, 1, 'ana');

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

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

DROP TABLE IF EXISTS `proizvodi`;
CREATE TABLE IF NOT EXISTS `proizvodi` (
  `idP` int NOT NULL,
  `naziv` varchar(45) COLLATE utf16_bin NOT NULL,
  `opis` varchar(150) COLLATE utf16_bin NOT NULL,
  `cena` int NOT NULL,
  `slika` varchar(45) COLLATE utf16_bin NOT NULL,
  PRIMARY KEY (`idP`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

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

INSERT INTO `proizvodi` (`idP`, `naziv`, `opis`, `cena`, `slika`) VALUES
(1, 'Fudbalska lopta', 'Adidas', 5000, 'lopta.png'),
(2, 'Skije', 'Elan skije za duboki sneg', 15000, 'skije.png'),
(3, 'Patike za trcanje', 'Asics Nimbus 17', 20000, 'patike.png'),
(4, 'Gumeni camac', 'Poklon: Vesla', 20000, 'camac.png');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `komentari`
--
ALTER TABLE `komentari`
  ADD CONSTRAINT `komentari_ibfk_1` FOREIGN KEY (`proizvod`) REFERENCES `proizvodi` (`idP`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  ADD CONSTRAINT `komentari_ibfk_2` FOREIGN KEY (`korisnik`) REFERENCES `korisnici` (`kor_ime`) ON DELETE RESTRICT ON UPDATE RESTRICT;

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