-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Mar 21, 2026 at 09:55 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: `pokloni`
--
DROP DATABASE IF EXISTS `pokloni`;
CREATE DATABASE IF NOT EXISTS `pokloni` DEFAULT CHARACTER SET utf16 COLLATE utf16_bin;
USE `pokloni`;

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

--
-- Table structure for table `aranzmani`
--

DROP TABLE IF EXISTS `aranzmani`;
CREATE TABLE IF NOT EXISTS `aranzmani` (
  `id_aranzman` int NOT NULL AUTO_INCREMENT,
  `naziv` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `opis` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `cena` int NOT NULL,
  `kolicina` int NOT NULL,
  PRIMARY KEY (`id_aranzman`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

--
-- Dumping data for table `aranzmani`
--

INSERT INTO `aranzmani` (`id_aranzman`, `naziv`, `opis`, `cena`, `kolicina`) VALUES
(1, 'Divan dan', 'Ruže i rafaelo', 5000, 5),
(2, 'Ponovo zaljubljeni', 'Suncokreti i bajadere', 6000, 4),
(3, 'Letnja ljubav', 'Orhideje', 7000, 3),
(4, 'Sunčano leto', 'Lale holandske', 4000, 0);

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

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

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `ime` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `prezime` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `kor_ime` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `lozinka` varchar(45) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL,
  `tip` varchar(45) CHARACTER SET utf16 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` (`ime`, `prezime`, `kor_ime`, `lozinka`, `tip`) VALUES
('Ana', 'Matic', 'ana', 'ana123', 'kupac'),
('Jova', 'Nikolic', 'jova', 'jova123', 'kupac'),
('Marko', 'Markovic', 'mare', 'mare123', 'radnik'),
('Mina', 'Minović', 'mina', 'mina123', 'kupac'),
('Nina', 'Ninić', 'nina', 'nina123', 'kupac');

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

--
-- Table structure for table `narudzine`
--

DROP TABLE IF EXISTS `narudzine`;
CREATE TABLE IF NOT EXISTS `narudzine` (
  `id_nar` int NOT NULL AUTO_INCREMENT,
  `ukupna_cena` int NOT NULL,
  `datum` date NOT NULL,
  `status` varchar(16) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL DEFAULT 'čekanje',
  `kor_ime` varchar(45) COLLATE utf16_bin NOT NULL,
  PRIMARY KEY (`id_nar`),
  KEY `kor_ime` (`kor_ime`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

--
-- Dumping data for table `narudzine`
--

INSERT INTO `narudzine` (`id_nar`, `ukupna_cena`, `datum`, `status`, `kor_ime`) VALUES
(1, 13000, '2026-03-10', 'prihvaćena', 'jova'),
(2, 7000, '2026-03-10', 'prihvaćena', 'ana'),
(3, 12000, '2026-03-11', 'čekanje', 'mina'),
(4, 11000, '2026-03-11', 'čekanje', 'nina');

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

--
-- Table structure for table `pripada_narudzbini`
--

DROP TABLE IF EXISTS `pripada_narudzbini`;
CREATE TABLE IF NOT EXISTS `pripada_narudzbini` (
  `kor_ime` varchar(45) COLLATE utf16_bin NOT NULL,
  `id_aranzman` int NOT NULL,
  `id_nar` int NOT NULL,
  PRIMARY KEY (`kor_ime`,`id_aranzman`,`id_nar`),
  KEY `id_aranzman` (`id_aranzman`),
  KEY `id_nar` (`id_nar`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

--
-- Dumping data for table `pripada_narudzbini`
--

INSERT INTO `pripada_narudzbini` (`kor_ime`, `id_aranzman`, `id_nar`) VALUES
('mina', 1, 3),
('jova', 2, 1),
('ana', 3, 2),
('jova', 3, 1),
('mina', 3, 3),
('nina', 3, 4),
('nina', 4, 4);

--
-- Constraints for dumped tables
--

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

--
-- Constraints for table `pripada_narudzbini`
--
ALTER TABLE `pripada_narudzbini`
  ADD CONSTRAINT `pripada_narudzbini_ibfk_1` FOREIGN KEY (`kor_ime`) REFERENCES `korisnici` (`kor_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `pripada_narudzbini_ibfk_2` FOREIGN KEY (`id_aranzman`) REFERENCES `aranzmani` (`id_aranzman`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `pripada_narudzbini_ibfk_3` FOREIGN KEY (`id_nar`) REFERENCES `narudzine` (`id_nar`) 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 */;
