-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jul 03, 2015 at 11:05 AM
-- Server version: 5.6.17-log
-- PHP Version: 5.5.12

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

--
-- Database: `rentacar`
--
CREATE DATABASE IF NOT EXISTS `rentacar` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `rentacar`;

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

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

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `korisnickoime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `lozinka` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `adresa` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `zemlja` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `brojdozvole` int(11) DEFAULT NULL,
  `admin_pravo` tinyint(4) NOT NULL,
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

INSERT INTO `korisnik` (`korisnickoime`, `lozinka`, `ime`, `prezime`, `adresa`, `zemlja`, `brojdozvole`, `admin_pravo`) VALUES
('bosko', 'sifra123', 'Bosko', 'Nikolic', 'Beograd, Bulevar kralja 73', 'Srbija', 12345678, 0),
('cmilos', 'sifra123', 'Milos', 'Cvetanovic', 'Vranjska 55, Vranje', 'Srbija', 33445566, 0),
('drasko', 'sifra123', 'Drazen', 'Draskovic', 'Beograd, Krunska 22', 'Srbija', 8877665, 0),
('gaga', 'sifra123', 'Dragomir', 'El Mezeni', 'Beograd, Ruzveltova bb', 'Srbija', 22334455, 0),
('rentabot', 'sifra123', 'Jovan', 'Memedovic', 'Krf', 'Grcka', 0, 1),
('rentacar', 'sifra123', 'Slobodan Kontiki', 'Micic', 'Santorini', 'Grcka', 0, 1),
('stojsasa', 'sifra123', 'Sasa', 'Stojanovic', 'Foca, Focanska 33', 'Republika Srpska', 55556666, 0);

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

--
-- Table structure for table `rezervacija`
--

DROP TABLE IF EXISTS `rezervacija`;
CREATE TABLE IF NOT EXISTS `rezervacija` (
  `idrez` int(11) NOT NULL AUTO_INCREMENT,
  `idvozila` int(11) NOT NULL,
  `korisnik` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `datumod` date NOT NULL,
  `datumdo` date NOT NULL,
  `zanaplatu` double NOT NULL,
  PRIMARY KEY (`idrez`),
  KEY `korisnik` (`korisnik`),
  KEY `idvozila` (`idvozila`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;

--
-- Dumping data for table `rezervacija`
--

INSERT INTO `rezervacija` (`idrez`, `idvozila`, `korisnik`, `datumod`, `datumdo`, `zanaplatu`) VALUES
(1, 2, 'bosko', '2015-06-18', '2015-06-21', 121.6),
(2, 3, 'drasko', '2015-06-22', '2015-06-23', 66),
(3, 4, 'drasko', '2015-07-16', '2015-07-19', 160),
(4, 5, 'stojsasa', '2015-07-16', '2015-07-17', 120),
(5, 6, 'cmilos', '2015-06-27', '2015-06-28', 160),
(6, 3, 'drasko', '2015-06-13', '2015-06-14', 66),
(7, 2, 'gaga', '2015-06-10', '2015-06-11', 76),
(8, 6, 'gaga', '2015-08-03', '2015-08-04', 160);

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

--
-- Table structure for table `vozilo`
--

DROP TABLE IF EXISTS `vozilo`;
CREATE TABLE IF NOT EXISTS `vozilo` (
  `idvozila` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `tipvozila` tinyint(4) NOT NULL,
  `mesto` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `opis` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `cena` double NOT NULL,
  `agencija` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idvozila`),
  KEY `agencija` (`agencija`),
  KEY `agencija_2` (`agencija`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;

--
-- Dumping data for table `vozilo`
--

INSERT INTO `vozilo` (`idvozila`, `naziv`, `tipvozila`, `mesto`, `opis`, `cena`, `agencija`) VALUES
(1, 'Mercedes A', 1, 'Krf', 'super auto, 4 putnika', 45, 'rentacar'),
(2, 'Opel Astra', 1, 'Krf', 'godiste: 2015. potrosnja: 5L', 38, 'rentacar'),
(3, 'Opel Corsa', 1, 'Krit', 'odlican, ima krov na otvaranje', 33, 'rentacar'),
(4, 'Golf cabrio', 1, 'Krit', 'godiste: 2015', 50, 'rentacar'),
(5, 'Brod ', 2, 'Krf', 'Za 8 putnika', 60, 'rentabot'),
(6, 'Katamaran', 2, 'Rodos', 'za 10-12 putnika, odlican za zurke', 80, 'rentabot');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `rezervacija`
--
ALTER TABLE `rezervacija`
  ADD CONSTRAINT `rezervacija_ibfk_2` FOREIGN KEY (`korisnik`) REFERENCES `korisnik` (`korisnickoime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `rezervacija_ibfk_1` FOREIGN KEY (`idvozila`) REFERENCES `vozilo` (`idvozila`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `vozilo`
--
ALTER TABLE `vozilo`
  ADD CONSTRAINT `vozilo_ibfk_1` FOREIGN KEY (`agencija`) REFERENCES `korisnik` (`korisnickoime`) 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 */;
