-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Oct 15, 2025 at 03:59 AM
-- Server version: 8.0.21
-- PHP Version: 7.4.9

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

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

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

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

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

INSERT INTO `korisnici` (`kor_ime`, `lozinka`, `ime`, `prezime`, `mejl`, `tip`) VALUES
('jeca', 'jeca123', 'Jelena', 'Jelic', 'jeca@gmail.com', 'kupac'),
('jova', 'jova123', 'Jovan', 'Jovic', 'jovan@gmail.com', 'kupac'),
('laza', 'laza123', 'Lazar', 'Lazic', 'laki@gmail.com', 'radnik'),
('maja', 'maja123', 'Maja', 'Majic', 'maja@gmail.com', 'radnik'),
('pera', 'pera123', 'Petar', 'Peric', 'peca@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,
  `kupac` varchar(50) NOT NULL,
  `cena` int NOT NULL,
  `status` varchar(50) NOT NULL,
  PRIMARY KEY (`idN`),
  KEY `kupac` (`kupac`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf16;

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

INSERT INTO `narudzbine` (`idN`, `kupac`, `cena`, `status`) VALUES
(1, 'pera', 550, 'u obradi'),
(2, 'jova', 2300, 'u obradi'),
(3, 'jova', 950, 'gotovo'),
(5, 'jeca', 1200, 'odbijeno');

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

--
-- Table structure for table `sendvici`
--

DROP TABLE IF EXISTS `sendvici`;
CREATE TABLE IF NOT EXISTS `sendvici` (
  `idS` int NOT NULL AUTO_INCREMENT,
  `naziv` varchar(70) NOT NULL,
  `cena` int NOT NULL,
  PRIMARY KEY (`idS`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf16;

--
-- Dumping data for table `sendvici`
--

INSERT INTO `sendvici` (`idS`, `naziv`, `cena`) VALUES
(1, 'kulen sendvic', 350),
(2, 'pecenica sendvic', 350),
(3, 'klasik burger', 550),
(4, 'smash burger', 600);

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

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

DROP TABLE IF EXISTS `stavke`;
CREATE TABLE IF NOT EXISTS `stavke` (
  `id` int NOT NULL AUTO_INCREMENT,
  `idNarudzbine` int NOT NULL,
  `idSendvica` int NOT NULL,
  `obrok` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idSendvica` (`idSendvica`),
  KEY `idNarudzbine` (`idNarudzbine`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf16;

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

INSERT INTO `stavke` (`id`, `idNarudzbine`, `idSendvica`, `obrok`) VALUES
(1, 1, 3, NULL),
(2, 2, 3, 'mali'),
(3, 2, 4, 'srednji'),
(4, 2, 4, NULL),
(5, 3, 3, 'veliki'),
(6, 5, 1, 'mali'),
(7, 5, 1, 'mali');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `narudzbine`
--
ALTER TABLE `narudzbine`
  ADD CONSTRAINT `fk_kupac_nar` FOREIGN KEY (`kupac`) REFERENCES `korisnici` (`kor_ime`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `stavke`
--
ALTER TABLE `stavke`
  ADD CONSTRAINT `fk_id_nar` FOREIGN KEY (`idNarudzbine`) REFERENCES `narudzbine` (`idN`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_id_sendvic` FOREIGN KEY (`idSendvica`) REFERENCES `sendvici` (`idS`) 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 */;
