-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 13, 2015 at 01:16 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: `bgsajamknjiga`
--

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

--
-- Table structure for table `autor`
--

CREATE TABLE IF NOT EXISTS `autor` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `middle` char(1) COLLATE utf8_unicode_ci NOT NULL,
  `surname` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `birthyear` year(4) NOT NULL,
  `email` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `active` tinyint(4) NOT NULL,
  PRIMARY KEY (`username`),
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `autor`
--

INSERT INTO `autor` (`username`, `password`, `name`, `middle`, `surname`, `birthyear`, `email`, `active`) VALUES
('drasko', 'sifra123', 'Drazen', 'D', 'Draskovic', 1986, 'drazen.draskovic@etf.rs', 1),
('joca', 'sifra123', 'Jovan', 'M', 'Djordjevic', 1947, 'jdjordjevic@etf.rs', 0),
('nbosko', 'sifra123', 'Bosko', 'D', 'Nikolic', 1975, 'nbosko@etf.rs', 1),
('zaki', 'sifra123', 'Zaharije', 'R', 'Radivojevic', 1979, 'zaki@etf.rs', 1);

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

--
-- Table structure for table `autor_knjiga`
--

CREATE TABLE IF NOT EXISTS `autor_knjiga` (
  `author` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `book` int(11) NOT NULL,
  PRIMARY KEY (`author`,`book`),
  KEY `book` (`book`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `autor_knjiga`
--

INSERT INTO `autor_knjiga` (`author`, `book`) VALUES
('drasko', 1),
('nbosko', 1),
('nbosko', 2),
('drasko', 3),
('joca', 4),
('nbosko', 4),
('zaki', 4),
('joca', 5),
('nbosko', 5),
('zaki', 5),
('joca', 6),
('zaki', 6),
('joca', 7),
('zaki', 7);

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

--
-- Table structure for table `izdavac`
--

CREATE TABLE IF NOT EXISTS `izdavac` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `address` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `PIB` int(9) NOT NULL,
  `active` tinyint(4) NOT NULL,
  PRIMARY KEY (`username`),
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `izdavac`
--

INSERT INTO `izdavac` (`username`, `password`, `name`, `address`, `PIB`, `active`) VALUES
('etf', 'sifra123', 'ETF - Akademska misao', 'Bulevar kralja Aleksandra 73', 100200300, 1),
('laguna', 'sifra123', 'Laguna d.o.o.', 'Resavska 33', 102016688, 1),
('nknjiga', 'sifra123', 'Narodna knjiga', 'Kralja Milana 58', 100103218, 0),
('vulkan', 'sifra123', 'Vulkan knjizare', 'Gospodara Vucica 245', 107895467, 1);

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

--
-- Table structure for table `knjiga`
--

CREATE TABLE IF NOT EXISTS `knjiga` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `ISBN10` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `numedition` int(11) NOT NULL DEFAULT '1',
  `yearedition` year(4) NOT NULL,
  `printnumber` int(11) NOT NULL,
  `soldnumber` int(11) NOT NULL,
  `price` double NOT NULL,
  `publisher` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ISBN10` (`ISBN10`),
  KEY `id` (`id`),
  KEY `publisher` (`publisher`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=8 ;

--
-- Dumping data for table `knjiga`
--

INSERT INTO `knjiga` (`id`, `title`, `ISBN10`, `numedition`, `yearedition`, `printnumber`, `soldnumber`, `price`, `publisher`) VALUES
(1, 'Internet programiranje - knjiga', '1371234560', 1, 2015, 200, 12, 615.39, 'etf'),
(2, 'JSP za pocetnike', '1871234560', 2, 2014, 150, 3, 499.5, 'nknjiga'),
(3, 'Testiranje softvera', '9761233210', 1, 2015, 250, 6, 769.23, 'etf'),
(4, 'Recnik IT pojmova', '7712345688', 1, 2012, 500, 48, 999.88, 'vulkan'),
(5, 'Osnovi racunarske tehnike', '3344555550', 4, 2012, 250, 82, 675.33, 'laguna'),
(6, 'Arhitektura racunara i interneta', '6565657878', 2, 2013, 250, 13, 813.88, 'laguna'),
(7, 'Arhitektura i organizacija racunara', '9988440123', 1, 2010, 50, 48, 385.5, 'etf');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `autor_knjiga`
--
ALTER TABLE `autor_knjiga`
  ADD CONSTRAINT `autor_knjiga_ibfk_2` FOREIGN KEY (`book`) REFERENCES `knjiga` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `autor_knjiga_ibfk_1` FOREIGN KEY (`author`) REFERENCES `autor` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `knjiga`
--
ALTER TABLE `knjiga`
  ADD CONSTRAINT `knjiga_ibfk_1` FOREIGN KEY (`publisher`) REFERENCES `izdavac` (`username`) 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 */;
