SET default_storage_engine=INNODB;

CREATE DATABASE  IF NOT EXISTS `sahovskisavez` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `sahovskisavez`;
-- MySQL dump 10.13  Distrib 5.6.17, for osx10.6 (i386)
--
-- Host: 127.0.0.1    Database: sahovskisavez
-- ------------------------------------------------------
-- Server version	5.7.17

/*!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 `analiza`
--

DROP TABLE IF EXISTS `analiza`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `analiza` (
  `SifA` int(11) NOT NULL AUTO_INCREMENT,
  `Potez` varchar(45) NOT NULL,
  `SifZ` int(11) NOT NULL,
  `SifK` int(11) NOT NULL,
  PRIMARY KEY (`SifA`),
  KEY `SifZ_st_idx` (`SifZ`),
  KEY `SifK_st_idx` (`SifK`),
  CONSTRAINT `SifK_stkljuc` FOREIGN KEY (`SifK`) REFERENCES `komentator` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `SifZ_st` FOREIGN KEY (`SifZ`) REFERENCES `potez` (`SifZ`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `analiza`
--

LOCK TABLES `analiza` WRITE;
/*!40000 ALTER TABLE `analiza` DISABLE KEYS */;
/*!40000 ALTER TABLE `analiza` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `komentator`
--

DROP TABLE IF EXISTS `komentator`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `komentator` (
  `SifK` int(11) NOT NULL,
  `iskustvo` int(11) NOT NULL,
  PRIMARY KEY (`SifK`),
  CONSTRAINT `SifK_st2` FOREIGN KEY (`SifK`) REFERENCES `korisnik` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `komentator`
--

LOCK TABLES `komentator` WRITE;
/*!40000 ALTER TABLE `komentator` DISABLE KEYS */;
INSERT INTO `komentator` (`SifK`, `iskustvo`) VALUES (1,5);
/*!40000 ALTER TABLE `komentator` 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` (
  `SifK` int(11) NOT NULL AUTO_INCREMENT,
  `Ime` varchar(45) NOT NULL,
  `Prezime` varchar(45) NOT NULL,
  `BrLK` int(11) NOT NULL,
  PRIMARY KEY (`SifK`),
  UNIQUE KEY `BrLK_UNIQUE` (`BrLK`)
) ENGINE=InnoDB AUTO_INCREMENT=4 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` (`SifK`, `Ime`, `Prezime`, `BrLK`) VALUES (1,'Pera','Peric',111),(2,'Marko','Markovic',222),(3,'Jovan','Jovanovic',333);
/*!40000 ALTER TABLE `korisnik` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `nagrada`
--

DROP TABLE IF EXISTS `nagrada`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `nagrada` (
  `SifN` int(11) NOT NULL AUTO_INCREMENT,
  `Opis` varchar(45) NOT NULL,
  `SifU` int(11) NOT NULL,
  PRIMARY KEY (`SifN`),
  KEY `SifU_st_idx` (`SifU`),
  CONSTRAINT `SifU_st` FOREIGN KEY (`SifU`) REFERENCES `ucestvovanje` (`SifU`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `nagrada`
--

LOCK TABLES `nagrada` WRITE;
/*!40000 ALTER TABLE `nagrada` DISABLE KEYS */;
INSERT INTO `nagrada` (`SifN`, `Opis`, `SifU`) VALUES (1,'opis1',2),(2,'opis2',2),(3,'opis3',2);
/*!40000 ALTER TABLE `nagrada` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `odigrana`
--

DROP TABLE IF EXISTS `odigrana`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `odigrana` (
  `SifT` int(11) NOT NULL,
  `SifP` int(11) NOT NULL,
  PRIMARY KEY (`SifP`),
  KEY `SifT_st_idx` (`SifT`),
  CONSTRAINT `SifP_st` FOREIGN KEY (`SifP`) REFERENCES `partija` (`SifP`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `SifT_st` FOREIGN KEY (`SifT`) REFERENCES `turnir` (`SifT`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `odigrana`
--

LOCK TABLES `odigrana` WRITE;
/*!40000 ALTER TABLE `odigrana` DISABLE KEYS */;
INSERT INTO `odigrana` (`SifT`, `SifP`) VALUES (1,1),(1,2);
/*!40000 ALTER TABLE `odigrana` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `partija`
--

DROP TABLE IF EXISTS `partija`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `partija` (
  `SifP` int(11) NOT NULL,
  `Vreme` int(11) NOT NULL,
  `Ishod` int(11) NOT NULL,
  `Beli` int(11) NOT NULL,
  `Crni` int(11) NOT NULL,
  PRIMARY KEY (`SifP`),
  KEY `Beli_st_idx` (`Beli`),
  KEY `Crni_st_idx` (`Crni`),
  CONSTRAINT `Beli_st` FOREIGN KEY (`Beli`) REFERENCES `sahist` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `Crni_st` FOREIGN KEY (`Crni`) REFERENCES `sahist` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `partija`
--

LOCK TABLES `partija` WRITE;
/*!40000 ALTER TABLE `partija` DISABLE KEYS */;
INSERT INTO `partija` (`SifP`, `Vreme`, `Ishod`, `Beli`, `Crni`) VALUES (1,10,1,1,2),(2,5,2,1,2);
/*!40000 ALTER TABLE `partija` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `potez`
--

DROP TABLE IF EXISTS `potez`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `potez` (
  `SifZ` int(11) NOT NULL AUTO_INCREMENT,
  `Potez` varchar(45) NOT NULL,
  `BrPoteza` int(11) NOT NULL,
  `SifP` int(11) NOT NULL,
  PRIMARY KEY (`SifZ`),
  KEY `SifP_st_idx` (`SifP`),
  CONSTRAINT `SifP_st3` FOREIGN KEY (`SifP`) REFERENCES `partija` (`SifP`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `potez`
--

LOCK TABLES `potez` WRITE;
/*!40000 ALTER TABLE `potez` DISABLE KEYS */;
/*!40000 ALTER TABLE `potez` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `sahist`
--

DROP TABLE IF EXISTS `sahist`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sahist` (
  `SifK` int(11) NOT NULL,
  `Rejting` int(11) NOT NULL,
  PRIMARY KEY (`SifK`),
  CONSTRAINT `SifK_st` FOREIGN KEY (`SifK`) REFERENCES `korisnik` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `sahist`
--

LOCK TABLES `sahist` WRITE;
/*!40000 ALTER TABLE `sahist` DISABLE KEYS */;
INSERT INTO `sahist` (`SifK`, `Rejting`) VALUES (1,1),(2,3);
/*!40000 ALTER TABLE `sahist` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `turnir`
--

DROP TABLE IF EXISTS `turnir`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `turnir` (
  `SifT` int(11) NOT NULL,
  `Naziv` varchar(45) NOT NULL,
  `Mesto` varchar(45) NOT NULL,
  `Datum` date NOT NULL,
  PRIMARY KEY (`SifT`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `turnir`
--

LOCK TABLES `turnir` WRITE;
/*!40000 ALTER TABLE `turnir` DISABLE KEYS */;
INSERT INTO `turnir` (`SifT`, `Naziv`, `Mesto`, `Datum`) VALUES (1,'ETF turnir','Beograd','1991-08-25');
/*!40000 ALTER TABLE `turnir` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `ucestvovanje`
--

DROP TABLE IF EXISTS `ucestvovanje`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ucestvovanje` (
  `SifU` int(11) NOT NULL,
  `SifT` int(11) NOT NULL,
  `SifK` int(11) NOT NULL,
  PRIMARY KEY (`SifU`),
  KEY `SifT_st_idx` (`SifT`),
  KEY `SifK_st_idx` (`SifK`),
  CONSTRAINT `SifK_st3` FOREIGN KEY (`SifK`) REFERENCES `korisnik` (`SifK`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `SifT_st3` FOREIGN KEY (`SifT`) REFERENCES `turnir` (`SifT`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `ucestvovanje`
--

LOCK TABLES `ucestvovanje` WRITE;
/*!40000 ALTER TABLE `ucestvovanje` DISABLE KEYS */;
INSERT INTO `ucestvovanje` (`SifU`, `SifT`, `SifK`) VALUES (1,1,1),(2,1,2);
/*!40000 ALTER TABLE `ucestvovanje` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping events for database 'sahovskisavez'
--

--
-- Dumping routines for database 'sahovskisavez'
--
/*!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 2017-11-21 11:02:49
