CREATE DATABASE  IF NOT EXISTS `project1` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `project1`;
-- MySQL dump 10.13  Distrib 5.7.17, for Win64 (x86_64)
--
-- Host: localhost    Database: project1
-- ------------------------------------------------------
-- Server version	5.7.21-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 `alarmlog_has_sensor`
--

DROP TABLE IF EXISTS `alarmlog_has_sensor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `alarmlog_has_sensor` (
  `Sensor_SensorID` int(11) NOT NULL,
  `AlarmLog_AlarmID` int(11) NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`Sensor_SensorID`,`AlarmLog_AlarmID`),
  KEY `fk_AlarmLog_has_Sensor_Sensor1_idx` (`Sensor_SensorID`),
  KEY `fk_alarmlog_has_sensor_Log1_idx` (`AlarmLog_AlarmID`),
  CONSTRAINT `fk_AlarmLog_has_Sensor_Sensor1` FOREIGN KEY (`Sensor_SensorID`) REFERENCES `sensor` (`SensorID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_alarmlog_has_sensor_Log2` FOREIGN KEY (`AlarmLog_AlarmID`) REFERENCES `log` (`logID`) 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 `alarmlog_has_sensor`
--

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

--
-- Table structure for table `log`
--

DROP TABLE IF EXISTS `log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log` (
  `logID` int(11) NOT NULL,
  `time` datetime DEFAULT NULL,
  PRIMARY KEY (`logID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `log`
--

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

--
-- Table structure for table `logins`
--

DROP TABLE IF EXISTS `logins`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logins` (
  `MasterID` int(11) NOT NULL,
  `username` varchar(100) NOT NULL,
  `phcstring` varchar(100) NOT NULL,
  PRIMARY KEY (`MasterID`),
  UNIQUE KEY `username_UNIQUE` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `logins`
--

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

--
-- Table structure for table `logstartup`
--

DROP TABLE IF EXISTS `logstartup`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `logstartup` (
  `logid` int(11) NOT NULL,
  `time` datetime(6) NOT NULL,
  PRIMARY KEY (`time`,`logid`),
  KEY `startup_has_log_idx` (`logid`),
  CONSTRAINT `startup_has_log` FOREIGN KEY (`logid`) REFERENCES `log` (`logID`) 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 `logstartup`
--

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

--
-- Table structure for table `sensor`
--

DROP TABLE IF EXISTS `sensor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sensor` (
  `SensorID` int(11) NOT NULL AUTO_INCREMENT,
  `Location` varchar(50) NOT NULL,
  `Type` varchar(45) NOT NULL,
  `pin` int(11) NOT NULL,
  PRIMARY KEY (`SensorID`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `sensor`
--

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

--
-- Table structure for table `status`
--

DROP TABLE IF EXISTS `status`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `status` (
  `id` int(11) NOT NULL,
  `system_armed` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `status`
--

LOCK TABLES `status` WRITE;
/*!40000 ALTER TABLE `status` DISABLE KEYS */;
INSERT INTO `status` VALUES (0,1);
/*!40000 ALTER TABLE `status` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `tagid`
--

DROP TABLE IF EXISTS `tagid`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tagid` (
  `id` int(11) NOT NULL,
  `tagid` varchar(20) DEFAULT NULL,
  `waiting_for_tagid` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `tagid`
--

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

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user` (
  `TagID` varchar(20) NOT NULL,
  `Name` varchar(45) NOT NULL,
  `SurName` varchar(45) DEFAULT NULL,
  `role` varchar(6) DEFAULT 'user',
  `logins_MasterID` int(11) DEFAULT NULL,
  PRIMARY KEY (`TagID`),
  KEY `fk_user_logins1_idx` (`logins_MasterID`),
  CONSTRAINT `fk_user_logins1` FOREIGN KEY (`logins_MasterID`) REFERENCES `logins` (`MasterID`) ON DELETE SET NULL ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user`
--

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

--
-- Table structure for table `user_has_log`
--

DROP TABLE IF EXISTS `user_has_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `user_has_log` (
  `user_TagID` varchar(20) NOT NULL,
  `Log_logID` int(11) NOT NULL,
  `time` datetime NOT NULL,
  `action` varchar(3) DEFAULT NULL,
  PRIMARY KEY (`user_TagID`,`Log_logID`,`time`),
  KEY `fk_user_has_Log_Log1_idx` (`Log_logID`),
  KEY `fk_user_has_Log_user1_idx` (`user_TagID`),
  CONSTRAINT `fk_user_has_Log_Log2` FOREIGN KEY (`Log_logID`) REFERENCES `log` (`logID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_user_has_Log_user1` FOREIGN KEY (`user_TagID`) REFERENCES `user` (`TagID`) 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 `user_has_log`
--

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

--
-- Dumping events for database 'project1'
--

--
-- Dumping routines for database 'project1'
--
/*!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-06-18  0:55:33
