-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jan 29, 2021 at 11:13 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: `menjacnica2021`
--
DROP DATABASE IF EXISTS `menjacnica2021`;
CREATE DATABASE IF NOT EXISTS `menjacnica2021` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE `menjacnica2021`;

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

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

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

INSERT INTO `korisnici` (`ime`, `prezime`, `kor_ime`, `lozinka`, `tip`) VALUES
('Jovan', 'Zivkovic', 'jova', 'jova123', 'kupac'),
('Milica', 'Peric', 'mica', 'mica123', 'radnik'),
('Milan', 'Jankovic', 'mile', 'mile123', 'radnik'),
('Una', 'Jovic', 'una', 'una123', 'kupac');

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

--
-- Table structure for table `kurs`
--

DROP TABLE IF EXISTS `kurs`;
CREATE TABLE IF NOT EXISTS `kurs` (
  `valuta` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `sr_kurs` double DEFAULT NULL,
  `stanje` double DEFAULT NULL,
  PRIMARY KEY (`valuta`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `kurs`
--

INSERT INTO `kurs` (`valuta`, `sr_kurs`, `stanje`) VALUES
('CAD', 75.48, 13452.34),
('CHF', 109.24, 10452.8),
('EUR', 117.57, 7654),
('RSD', 1, 100000),
('USD', 97.18, 3765.99);

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

--
-- Table structure for table `status`
--

DROP TABLE IF EXISTS `status`;
CREATE TABLE IF NOT EXISTS `status` (
  `status_trans` varchar(32) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`status_trans`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `status`
--

INSERT INTO `status` (`status_trans`) VALUES
('neobradjeno'),
('odbijeno'),
('prihvaceno');

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

--
-- Table structure for table `transakcije`
--

DROP TABLE IF EXISTS `transakcije`;
CREATE TABLE IF NOT EXISTS `transakcije` (
  `idT` int NOT NULL AUTO_INCREMENT,
  `kupac` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `za_konverziju` double DEFAULT NULL,
  `trenutna_valuta` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `zeljena_valuta` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `posle_konverzije` double DEFAULT NULL,
  `status` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`idT`),
  KEY `kupac` (`kupac`),
  KEY `trenutna_valuta` (`trenutna_valuta`),
  KEY `zeljena_valuta` (`zeljena_valuta`),
  KEY `status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `transakcije`
--

INSERT INTO `transakcije` (`idT`, `kupac`, `za_konverziju`, `trenutna_valuta`, `zeljena_valuta`, `posle_konverzije`, `status`) VALUES
(1, 'jova', 1000, 'RSD', 'EUR', 8.5, 'neobradjeno'),
(2, 'una', 105, 'CHF', 'RSD', 11470.7, 'prihvaceno');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `transakcije`
--
ALTER TABLE `transakcije`
  ADD CONSTRAINT `transakcije_ibfk_1` FOREIGN KEY (`kupac`) REFERENCES `korisnici` (`kor_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `transakcije_ibfk_2` FOREIGN KEY (`trenutna_valuta`) REFERENCES `kurs` (`valuta`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `transakcije_ibfk_3` FOREIGN KEY (`zeljena_valuta`) REFERENCES `kurs` (`valuta`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `transakcije_ibfk_4` FOREIGN KEY (`status`) REFERENCES `status` (`status_trans`) 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 */;
