-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Dec 26, 2017 at 04:10 PM
-- 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: `biblioteka2017`
--
CREATE DATABASE IF NOT EXISTS `biblioteka2017` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `biblioteka2017`;

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

--
-- Table structure for table `iznajmljeno`
--

DROP TABLE IF EXISTS `iznajmljeno`;
CREATE TABLE IF NOT EXISTS `iznajmljeno` (
  `Username` varchar(45) NOT NULL,
  `Naslov` varchar(100) NOT NULL,
  `DatumOd` date DEFAULT NULL,
  `DatumDo` date DEFAULT NULL,
  PRIMARY KEY (`Username`,`Naslov`),
  KEY `knjiga1_idx` (`Naslov`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `iznajmljeno`
--

INSERT INTO `iznajmljeno` (`Username`, `Naslov`, `DatumOd`, `DatumDo`) VALUES
('marko', 'Rat i mir', '2017-12-09', '2017-12-29'),
('marko', 'Zlocin i kazna', '2017-12-09', '2017-12-29'),
('pera', 'Ana Karenjina', '2017-12-10', '2017-12-30'),
('pera', 'Prokleta avlija', '2017-12-04', '2017-12-24'),
('pera', 'Rat i mir', '2017-12-10', '2017-12-30');

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

--
-- Table structure for table `knjige`
--

DROP TABLE IF EXISTS `knjige`;
CREATE TABLE IF NOT EXISTS `knjige` (
  `Naslov` varchar(100) NOT NULL,
  `Autor` varchar(100) NOT NULL,
  `Kolicina` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Naslov`),
  UNIQUE KEY `Naslov_UNIQUE` (`Naslov`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `knjige`
--

INSERT INTO `knjige` (`Naslov`, `Autor`, `Kolicina`) VALUES
('Ana Karenjina', 'Lav Tolstoj', 9),
('Braca Karamazov', 'Fjodor Dostojevski', 3),
('Dervis i smrt', 'Mesa Selimovic', 1),
('Necista krv', 'Bora Stankovic', 2),
('Prokleta avlija', 'Ivo Andric', 7),
('Rat i mir', 'Lav Tolstoj', 5),
('Zlocin i kazna', 'Fjodor Dostojevski', 6);

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

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

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `Ime` varchar(20) DEFAULT NULL,
  `Prezime` varchar(45) DEFAULT NULL,
  `Username` varchar(45) NOT NULL,
  `Password` varchar(45) NOT NULL,
  `Tip` int(11) NOT NULL COMMENT '1 - bibliotekar, 0 - clan',
  PRIMARY KEY (`Username`),
  UNIQUE KEY `Username_UNIQUE` (`Username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

INSERT INTO `korisnik` (`Ime`, `Prezime`, `Username`, `Password`, `Tip`) VALUES
('Nada', 'Bibliotekarka', 'bibliotekar1', 'sifra123', 1),
('Marko', 'Markovic', 'marko', 'marko123', 0),
('Nikola', 'Nikolic', 'nikola', 'nikola123', 0),
('Petar', 'Petrovic', 'pera', 'pera123', 0),
('Stefan', 'Stefanovic', 'stefan', 'stefan123', 0);

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

--
-- Table structure for table `rezervisano`
--

DROP TABLE IF EXISTS `rezervisano`;
CREATE TABLE IF NOT EXISTS `rezervisano` (
  `Username` varchar(45) NOT NULL,
  `Naslov` varchar(100) NOT NULL,
  `Status` varchar(45) DEFAULT NULL,
  `Datum` date DEFAULT NULL,
  PRIMARY KEY (`Username`,`Naslov`),
  KEY `knjiga2_idx` (`Naslov`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `rezervisano`
--

INSERT INTO `rezervisano` (`Username`, `Naslov`, `Status`, `Datum`) VALUES
('marko', 'Braca Karamazov', 'Cekanje', '2017-12-24'),
('marko', 'Rat i mir', 'Odobreno', '2017-12-08'),
('nikola', 'Braca Karamazov', 'Cekanje', '2017-12-23'),
('stefan', 'Braca Karamazov', 'Cekanje', '2017-12-22');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `iznajmljeno`
--
ALTER TABLE `iznajmljeno`
  ADD CONSTRAINT `knjiga1` FOREIGN KEY (`Naslov`) REFERENCES `knjige` (`Naslov`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `user1` FOREIGN KEY (`Username`) REFERENCES `korisnik` (`Username`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Constraints for table `rezervisano`
--
ALTER TABLE `rezervisano`
  ADD CONSTRAINT `knjiga2` FOREIGN KEY (`Naslov`) REFERENCES `knjige` (`Naslov`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `user2` FOREIGN KEY (`Username`) REFERENCES `korisnik` (`Username`) ON DELETE NO ACTION ON UPDATE NO ACTION;

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