-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 06, 2016 at 04:25 AM
-- Server version: 5.6.17
-- 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: `restorani2016`
--
CREATE DATABASE IF NOT EXISTS `restorani2016` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `restorani2016`;

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

--
-- 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(64) COLLATE utf8_unicode_ci NOT NULL,
  `eposta` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `is_admin` 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`, `eposta`, `is_admin`) VALUES
('admin1', 'sifra123', 'Dragance Miladinovic', 'draganche@etf.rs', 1),
('admin2', 'sifra123', 'Nikola Tisic', 'nikolica@etf.rs', 1),
('bosko', 'sifra123', 'Bosko Nikolic', 'nbosko@etf.rs', 0),
('cmilos', 'sifra123', 'Milos Cvetanovic', 'cmilos@etf.rs', 0),
('drasko', 'sifra123', 'Drazen Draskovic', 'draskovic@etf.rs', 0),
('sanja', 'sifra123', 'Sanja Delcev', 'sanjad@etf.rs', 0);

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

--
-- Table structure for table `restoran`
--

DROP TABLE IF EXISTS `restoran`;
CREATE TABLE IF NOT EXISTS `restoran` (
  `naziv` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `adresa` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `grad` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `opis` varchar(400) COLLATE utf8_unicode_ci NOT NULL,
  `brojmesta` int(11) NOT NULL,
  `tip` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`naziv`),
  KEY `tip` (`tip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `restoran`
--

INSERT INTO `restoran` (`naziv`, `adresa`, `grad`, `opis`, `brojmesta`, `tip`) VALUES
('Akustik Konoba', 'Cara Dusana 13', 'Beograd', 'tradicionalna kuhinja', 12, 'Etno restorani'),
('Caruso', 'Terazije 10', 'Beograd', 'Lep pogled', 8, 'Restorani internacionalni'),
('Kovac', 'Bulevar oslobodjenja 222', 'Beograd', 'dobra hrana', 10, 'Etno restorani'),
('Orasac', 'Bulevar kralja Aleksandra 100', 'Beograd', 'Dobar rostilj!', 20, 'Restorani domace kuhinje');

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

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

DROP TABLE IF EXISTS `rezervacija`;
CREATE TABLE IF NOT EXISTS `rezervacija` (
  `idrezervacije` int(11) NOT NULL AUTO_INCREMENT,
  `korisnickoime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `nazivrestorana` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `brojgostiju` int(11) NOT NULL,
  `datumrez` datetime NOT NULL,
  PRIMARY KEY (`idrezervacije`),
  KEY `korisnickoime` (`korisnickoime`,`nazivrestorana`),
  KEY `nazivrestorana` (`nazivrestorana`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;

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

INSERT INTO `rezervacija` (`idrezervacije`, `korisnickoime`, `nazivrestorana`, `brojgostiju`, `datumrez`) VALUES
(1, 'bosko', 'Orasac', 4, '2016-06-08 20:00:00'),
(2, 'bosko', 'Akustik Konoba', 3, '2016-06-10 21:00:00'),
(3, 'drasko', 'Caruso', 1, '2016-06-11 22:00:00'),
(4, 'sanja', 'Caruso', 1, '2016-06-11 22:00:00'),
(5, 'cmilos', 'Orasac', 4, '2016-06-09 12:00:00'),
(6, 'cmilos', 'Kovac', 3, '2016-06-09 14:00:00');

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

--
-- Table structure for table `tip_restorana`
--

DROP TABLE IF EXISTS `tip_restorana`;
CREATE TABLE IF NOT EXISTS `tip_restorana` (
  `tip` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`tip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `tip_restorana`
--

INSERT INTO `tip_restorana` (`tip`) VALUES
('Etno restorani'),
('Grcka'),
('Indijski'),
('Italijanski'),
('Kineska'),
('Meksicki'),
('Restorani domace kuhinje'),
('Restorani internacionalni');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `restoran`
--
ALTER TABLE `restoran`
  ADD CONSTRAINT `restoran_ibfk_1` FOREIGN KEY (`tip`) REFERENCES `tip_restorana` (`tip`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rezervacija`
--
ALTER TABLE `rezervacija`
  ADD CONSTRAINT `rezervacija_ibfk_2` FOREIGN KEY (`nazivrestorana`) REFERENCES `restoran` (`naziv`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `rezervacija_ibfk_1` FOREIGN KEY (`korisnickoime`) 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 */;
