-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: May 07, 2016 at 03:35 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: `kupovinastana2016`
--
CREATE DATABASE IF NOT EXISTS `kupovinastana2016` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `kupovinastana2016`;

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

--
-- Table structure for table `korisnici`
--

DROP TABLE IF EXISTS `korisnici`;
CREATE TABLE IF NOT EXISTS `korisnici` (
  `username` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `password` 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,
  `racun` int(15) NOT NULL,
  `stanje_racuna` double DEFAULT NULL,
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnici`
--

INSERT INTO `korisnici` (`username`, `password`, `ime`, `prezime`, `adresa`, `racun`, `stanje_racuna`) VALUES
('drazen.draskovic@etf.rs', 'sifra123', 'Drazen', 'Draskovic', 'Bulevar Nikole Tesle 66', 223344556, 45000),
('jovan.jovanovic.120234@student.etf.rs', 'sifra123', 'Jovan', 'Jovanovic', 'Trg republike 22', 33445566, 15700),
('petar.petrovic@etf.rs', 'sifra123', 'Petar', 'Petrovic', 'Cara Dusana 123', 1112223344, 80000),
('sanja.delcev.153322@student.etf.rs', 'sifra123', 'Sanja', 'Delcev', 'Bulevar Mihajla Pupina 77', 334455667, 62500);

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

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

DROP TABLE IF EXISTS `rezervacija`;
CREATE TABLE IF NOT EXISTS `rezervacija` (
  `idrez` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `idstan` int(11) NOT NULL,
  `uplaceno` tinyint(1) NOT NULL,
  PRIMARY KEY (`idrez`),
  KEY `username` (`username`),
  KEY `idstan` (`idstan`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;

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

INSERT INTO `rezervacija` (`idrez`, `username`, `idstan`, `uplaceno`) VALUES
(1, 'drazen.draskovic@etf.rs', 1, 0),
(2, 'sanja.delcev.153322@student.etf.rs', 2, 1);

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

--
-- Table structure for table `stan`
--

DROP TABLE IF EXISTS `stan`;
CREATE TABLE IF NOT EXISTS `stan` (
  `idstan` int(11) NOT NULL AUTO_INCREMENT,
  `vrsta` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `blok` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  `sprat` int(11) NOT NULL,
  `garaza` tinyint(1) NOT NULL,
  `kvadratura` double NOT NULL,
  `brojsoba` int(11) NOT NULL,
  `brojkupatila` int(11) NOT NULL,
  `cena` double NOT NULL,
  PRIMARY KEY (`idstan`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;

--
-- Dumping data for table `stan`
--

INSERT INTO `stan` (`idstan`, `vrsta`, `blok`, `sprat`, `garaza`, `kvadratura`, `brojsoba`, `brojkupatila`, `cena`) VALUES
(1, 'dvosobni', 'A', 2, 1, 60, 2, 2, 56000),
(2, 'trosobni', 'B', 3, 1, 78, 3, 2, 69000),
(3, 'cetvorosobni', 'A', 5, 0, 92, 4, 3, 90000);

--
-- Constraints for dumped tables
--

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