-- phpMyAdmin SQL Dump
-- version 5.0.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jul 08, 2022 at 08:31 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";
SET @@global.time_zone='+00:00';
SET @@session.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: `kasica2022`
--
CREATE DATABASE IF NOT EXISTS `kasica2022` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `kasica2022`;

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

--
-- Table structure for table `kategorije`
--

DROP TABLE IF EXISTS `kategorije`;
CREATE TABLE IF NOT EXISTS `kategorije` (
  `naziv` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`naziv`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `kategorije`
--

INSERT INTO `kategorije` (`naziv`) VALUES
('osnovno'),
('ostalo'),
('prihodi'),
('zabava');

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

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

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `korisnicko_ime` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `lozinka` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `ime` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `prezime` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `tip` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `prihodi` decimal(10,2) DEFAULT NULL,
  `osnovno` decimal(10,2) DEFAULT NULL,
  `zabava` decimal(10,2) DEFAULT NULL,
  `ostalo` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`korisnicko_ime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

INSERT INTO `korisnici` (`korisnicko_ime`, `lozinka`, `ime`, `prezime`, `tip`, `prihodi`, `osnovno`, `zabava`, `ostalo`) VALUES
('ana', 'anica', 'Ana', 'Antonijevic', 'admin', NULL, NULL, NULL, NULL),
('kaca', 'kaca123', 'Katarina', 'Katic', 'korisnik', '22991.82', '34815.34', '8647.51', '4488.72'),
('pera', 'pera123', 'Petar', 'Petrovic', 'korisnik', '53588.60', '17380.20', '10170.02', '10724.94'),
('sima', 'sima123', 'Sima', 'Simic', 'korisnik', '35126.80', '17088.30', '10509.07', '8213.76');

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

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

DROP TABLE IF EXISTS `transakcije`;
CREATE TABLE IF NOT EXISTS `transakcije` (
  `korisnik` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `datum` date NOT NULL,
  `kategorija` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `iznos` decimal(10,2) NOT NULL,
  `id` int NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`),
  KEY `user` (`korisnik`),
  KEY `category` (`kategorija`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

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

INSERT INTO `transakcije` (`korisnik`, `datum`, `kategorija`, `iznos`, `id`) VALUES
('kaca', '2022-07-02', 'zabava', '8647.51', 1),
('pera', '2022-07-08', 'osnovno', '17380.20', 2),
('pera', '2022-07-01', 'prihodi', '26794.30', 3),
('kaca', '2022-07-06', 'ostalo', '4488.72', 4),
('pera', '2022-07-07', 'ostalo', '10724.94', 5),
('sima', '2022-07-05', 'osnovno', '14981.67', 6),
('sima', '2022-07-03', 'prihodi', '35126.80', 7),
('kaca', '2022-07-04', 'osnovno', '15465.42', 8),
('kaca', '2022-07-03', 'osnovno', '15745.75', 9),
('sima', '2022-07-08', 'ostalo', '8213.76', 10),
('sima', '2022-07-01', 'osnovno', '2106.63', 11),
('kaca', '2022-07-07', 'osnovno', '3604.17', 12),
('pera', '2022-07-01', 'zabava', '10170.02', 13),
('kaca', '2022-07-04', 'prihodi', '22991.82', 14),
('sima', '2022-07-03', 'zabava', '10509.07', 15),
('pera', '2022-07-08', 'prihodi','26794.30', 16);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `transakcije`
--
ALTER TABLE `transakcije`
  ADD CONSTRAINT `fk_cat` FOREIGN KEY (`kategorija`) REFERENCES `kategorije` (`naziv`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_user` FOREIGN KEY (`korisnik`) REFERENCES `korisnici` (`korisnicko_ime`) 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 */;
