CREATE DATABASE  IF NOT EXISTS `mojekrofne2018` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `mojekrofne2018`;
-- MySQL dump 10.13  Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: 127.0.0.1    Database: mojekrofne2018
-- ------------------------------------------------------
-- Server version	5.7.20-log

/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `dodaci`
--

DROP TABLE IF EXISTS `dodaci`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dodaci` (
  `idDod` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(45) DEFAULT NULL,
  `cena` int(11) DEFAULT NULL,
  PRIMARY KEY (`idDod`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `dodaci`
--

LOCK TABLES `dodaci` WRITE;
/*!40000 ALTER TABLE `dodaci` DISABLE KEYS */;
INSERT INTO `dodaci` VALUES (1,'cokoladne mrvice',50),(2,'plazma',20),(3,'kokos',20),(4,'cimet',20),(5,'nutela',50),(6,'karamela',30);
/*!40000 ALTER TABLE `dodaci` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `korisnik`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `korisnik` (
  `username` varchar(45) NOT NULL,
  `password` varchar(45) DEFAULT NULL,
  `ime` varchar(45) DEFAULT NULL,
  `prezime` varchar(45) DEFAULT NULL,
  `tip` int(11) DEFAULT NULL,
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `korisnik` WRITE;
/*!40000 ALTER TABLE `korisnik` DISABLE KEYS */;
INSERT INTO `korisnik` VALUES ('mika','mika123','Mika','Mikic',0),('pera','pera123','Petar','Petrovic',0),('radnik','radnik123','Nikola','Nikolic',1),('zika','zika123','Zika','Zikic',0);
/*!40000 ALTER TABLE `korisnik` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `krofne`
--

DROP TABLE IF EXISTS `krofne`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `krofne` (
  `idKro` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(45) DEFAULT NULL,
  `cena` int(11) DEFAULT NULL,
  PRIMARY KEY (`idKro`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `krofne`
--

LOCK TABLES `krofne` WRITE;
/*!40000 ALTER TABLE `krofne` DISABLE KEYS */;
INSERT INTO `krofne` VALUES (1,'krofna cokolada',100),(2,'krofna vanila',120),(3,'krofna milka',150),(4,'krofna visnja',90);
/*!40000 ALTER TABLE `krofne` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `krofnedodaci`
--

DROP TABLE IF EXISTS `krofnedodaci`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `krofnedodaci` (
  `idKro` int(11) NOT NULL,
  `idDod` int(11) NOT NULL,
  PRIMARY KEY (`idKro`,`idDod`),
  KEY `dodaci_idx` (`idDod`),
  CONSTRAINT `dodaci` FOREIGN KEY (`idDod`) REFERENCES `dodaci` (`idDod`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `krofne` FOREIGN KEY (`idKro`) REFERENCES `krofne` (`idKro`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `krofnedodaci`
--

LOCK TABLES `krofnedodaci` WRITE;
/*!40000 ALTER TABLE `krofnedodaci` DISABLE KEYS */;
INSERT INTO `krofnedodaci` VALUES (1,1),(2,1),(3,1),(4,1),(1,2),(2,2),(3,2),(4,2),(1,3),(2,3),(3,3),(4,3),(1,4),(2,4),(4,4),(1,5),(2,5),(2,6);
/*!40000 ALTER TABLE `krofnedodaci` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `narudzbina`
--

DROP TABLE IF EXISTS `narudzbina`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `narudzbina` (
  `idNar` int(11) NOT NULL AUTO_INCREMENT,
  `brStavke` int(11) NOT NULL,
  `idKup` varchar(45) NOT NULL,
  `idKro` int(11) NOT NULL,
  `idDod1` int(11) DEFAULT NULL,
  `idDod2` int(11) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  PRIMARY KEY (`idNar`,`brStavke`,`idKup`),
  KEY `krof_idx` (`idKro`),
  KEY `dod_idx` (`idDod1`),
  KEY `kor_idx` (`idKup`),
  KEY `dod2_idx` (`idDod2`),
  CONSTRAINT `dod1` FOREIGN KEY (`idDod1`) REFERENCES `dodaci` (`idDod`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `dod2` FOREIGN KEY (`idDod2`) REFERENCES `dodaci` (`idDod`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `kor` FOREIGN KEY (`idKup`) REFERENCES `korisnik` (`username`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `krof` FOREIGN KEY (`idKro`) REFERENCES `krofne` (`idKro`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `narudzbina`
--

LOCK TABLES `narudzbina` WRITE;
/*!40000 ALTER TABLE `narudzbina` DISABLE KEYS */;
INSERT INTO `narudzbina` VALUES (1,1,'pera',1,NULL,NULL,1),(2,1,'zika',3,1,NULL,0),(2,2,'zika',2,2,3,0),(3,1,'mika',1,1,2,0),(3,2,'mika',4,2,NULL,0);
/*!40000 ALTER TABLE `narudzbina` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2018-02-05 22:04:06
