-- phpMyAdmin SQL Dump
-- version 4.6.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 04, 2017 at 08:42 AM
-- Server version: 5.7.14
-- PHP Version: 7.0.10

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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: `mobprovajderi2017`
--
CREATE DATABASE IF NOT EXISTS `mobprovajderi2017` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `mobprovajderi2017`;

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

--
-- Table structure for table `korisnik`
--

CREATE TABLE `korisnik` (
  `username` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `jmbg` varchar(13) COLLATE utf8_unicode_ci NOT NULL,
  `email` varchar(32) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnik`
--

INSERT INTO `korisnik` (`username`, `password`, `ime`, `prezime`, `jmbg`, `email`) VALUES
('drasko', 'sifra123', 'Dražen', 'Drašković', '1612987876543', 'draskovic@etf.bg.ac.rs'),
('nbosko', 'sifra123', 'Boško', 'Nikolić', '0808975757575', 'nbosko@etf.bg.ac.rs'),
('neca', 'sifra123', 'Nemanja', 'Kojić', '0909999888777', 'kojic@etf.bg.ac.rs'),
('sanja', 'sifra123', 'Sanja', 'Delčeva', '1010999666333', 'sanja@etf.bg.ac.rs');

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

--
-- Table structure for table `paket`
--

CREATE TABLE `paket` (
  `id_paket` int(11) NOT NULL,
  `naziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `broj_minuta_besp` int(11) NOT NULL,
  `broj_poruka_besp` int(11) NOT NULL,
  `broj_mb_besp` int(11) NOT NULL,
  `cena_bez_pdv` double NOT NULL,
  `aktuelan` tinyint(4) NOT NULL,
  `id_provajder` varchar(3) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `paket`
--

INSERT INTO `paket` (`id_paket`, `naziv`, `broj_minuta_besp`, `broj_poruka_besp`, `broj_mb_besp`, `cena_bez_pdv`, `aktuelan`, `id_provajder`) VALUES
(1, 'Miks S', 100, 200, 600, 799, 1, 'mts'),
(2, 'Miks M', 300, 400, 1000, 1399, 1, 'mts'),
(3, 'Miks L', 400, 500, 1200, 1699, 1, 'mts'),
(4, 'Miks XL', 600, 1000, 2000, 1999, 1, 'mts'),
(5, 'Priča', 100, 100, 0, 599, 0, 'mts'),
(6, 'Prenesi i surfuj S', 150, 250, 250, 950, 1, 'tel'),
(7, 'Prenesi i surfuj M', 250, 400, 400, 1250, 1, 'tel'),
(8, 'Premium+', 5000, 5000, 15000, 6995, 1, 'tel'),
(9, 'Prenesi Start', 100, 300, 50, 495, 0, 'tel');

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

--
-- Table structure for table `provajder`
--

CREATE TABLE `provajder` (
  `id_provajdera` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `naziv` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `adresa` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `PIB` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `provajder`
--

INSERT INTO `provajder` (`id_provajdera`, `password`, `naziv`, `adresa`, `PIB`) VALUES
('mts', 'sifra321', 'Telekom Srbija', 'Bulevar umetnosti 4', 100002887),
('tel', 'sifra321', 'Telenor', 'Omladinskih brigada 90', 104318304),
('vip', 'sifra321', 'Vip Mobile d.o.o', 'Omladinskih brigada 21', 104704549);

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

--
-- Table structure for table `racun`
--

CREATE TABLE `racun` (
  `id_racun` int(11) NOT NULL,
  `mesec` int(11) NOT NULL,
  `godina` int(11) NOT NULL,
  `min_potroseni` int(11) NOT NULL,
  `sms_potroseni` int(11) NOT NULL,
  `mb_potroseni` double NOT NULL,
  `iznos_sa_pdv` double NOT NULL,
  `id_korisnik` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `id_paket` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `racun`
--

INSERT INTO `racun` (`id_racun`, `mesec`, `godina`, `min_potroseni`, `sms_potroseni`, `mb_potroseni`, `iznos_sa_pdv`, `id_korisnik`, `id_paket`) VALUES
(1, 1, 2017, 100, 198, 550, 958.8, 'nbosko', 1),
(2, 2, 2017, 99, 200, 455, 958.8, 'nbosko', 1),
(3, 3, 2017, 120, 250, 500, 1546.8, 'nbosko', 1),
(4, 4, 2017, 95, 400, 800, 6958.8, 'nbosko', 1),
(5, 5, 2017, 99, 199, 599, 958.8, 'nbosko', 1),
(6, 1, 2017, 299, 399, 546, 1678.8, 'drasko', 2),
(7, 2, 2017, 330, 440, 885, 1959, 'drasko', 2),
(8, 3, 2017, 295, 500, 990, 2278.8, 'drasko', 2),
(9, 4, 2017, 330, 440, 1050, 3550.8, 'drasko', 2),
(10, 3, 2017, 230, 320, 320, 1500, 'neca', 7),
(11, 4, 2017, 240, 399, 388, 1500, 'neca', 7),
(12, 5, 2017, 145, 300, 300, 2640, 'neca', 6),
(13, 1, 2017, 249, 398, 395, 1500, 'sanja', 7),
(14, 2, 2017, 240, 399, 400, 1500, 'sanja', 7),
(15, 3, 2017, 250, 400, 500, 3900, 'sanja', 7),
(16, 4, 2017, 500, 399, 399, 5100, 'sanja', 7);

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

--
-- Table structure for table `trenutni_paketi`
--

CREATE TABLE `trenutni_paketi` (
  `id` int(11) NOT NULL,
  `id_korisnik` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `id_paket` int(11) NOT NULL,
  `datum_izmene` timestamp NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `trenutni_paketi`
--

INSERT INTO `trenutni_paketi` (`id`, `id_korisnik`, `id_paket`, `datum_izmene`) VALUES
(1, 'nbosko', 1, '2017-01-01 09:00:00'),
(2, 'drasko', 2, '2016-03-01 09:15:00'),
(3, 'sanja', 7, '2016-10-20 09:30:00'),
(4, 'neca', 6, '2017-05-02 13:45:45');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `korisnik`
--
ALTER TABLE `korisnik`
  ADD PRIMARY KEY (`username`);

--
-- Indexes for table `paket`
--
ALTER TABLE `paket`
  ADD PRIMARY KEY (`id_paket`),
  ADD KEY `id_provajder` (`id_provajder`);

--
-- Indexes for table `provajder`
--
ALTER TABLE `provajder`
  ADD PRIMARY KEY (`id_provajdera`);

--
-- Indexes for table `racun`
--
ALTER TABLE `racun`
  ADD PRIMARY KEY (`id_racun`),
  ADD KEY `id_korisnik` (`id_korisnik`),
  ADD KEY `id_paket` (`id_paket`);

--
-- Indexes for table `trenutni_paketi`
--
ALTER TABLE `trenutni_paketi`
  ADD PRIMARY KEY (`id`),
  ADD KEY `id_korisnik` (`id_korisnik`),
  ADD KEY `id_paket` (`id_paket`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `paket`
--
ALTER TABLE `paket`
  MODIFY `id_paket` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
--
-- AUTO_INCREMENT for table `racun`
--
ALTER TABLE `racun`
  MODIFY `id_racun` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT for table `trenutni_paketi`
--
ALTER TABLE `trenutni_paketi`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `paket`
--
ALTER TABLE `paket`
  ADD CONSTRAINT `paket_ibfk_1` FOREIGN KEY (`id_provajder`) REFERENCES `provajder` (`id_provajdera`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `racun`
--
ALTER TABLE `racun`
  ADD CONSTRAINT `racun_ibfk_2` FOREIGN KEY (`id_korisnik`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `racun_ibfk_3` FOREIGN KEY (`id_paket`) REFERENCES `paket` (`id_paket`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `trenutni_paketi`
--
ALTER TABLE `trenutni_paketi`
  ADD CONSTRAINT `trenutni_paketi_ibfk_1` FOREIGN KEY (`id_korisnik`) REFERENCES `korisnik` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `trenutni_paketi_ibfk_2` FOREIGN KEY (`id_paket`) REFERENCES `paket` (`id_paket`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!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 */;
