CREATE DATABASE  IF NOT EXISTS `db_weerstation` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `db_weerstation`;
--
-- Host: localhost    Database: db_weerstation
-- ------------------------------------------------------


--
-- Table structure for table `grafiek`
--

CREATE TABLE `grafiek` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Type` varchar(55) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `grafiek`
--

INSERT INTO `grafiek` VALUES (1,'Lijngrafiek'),(2,'Blokdiagram');

--
-- Table structure for table `grens`
--

CREATE TABLE `grens` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Grens` varchar(45) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `grens`
--

INSERT INTO `grens` VALUES (1,'bovengrens'),(2,'ondergrens');

--
-- Table structure for table `instellingen`
--

CREATE TABLE `instellingen` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `LaatstAangepast` datetime NOT NULL,
  `gebruiker_Login` varchar(55) NOT NULL,
  `kleur_kleurCode` varchar(8) NOT NULL,
  PRIMARY KEY (`ID`,`gebruiker_Login`,`kleur_kleurCode`),
  KEY `fk_instellingen_gebruiker1_idx` (`gebruiker_Login`),
  KEY `fk_instellingen_kleur1_idx` (`kleur_kleurCode`),
  CONSTRAINT `fk_instellingen_gebruiker1` FOREIGN KEY (`gebruiker_Login`) REFERENCES `gebruiker` (`Login`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_instellingen_kleur1` FOREIGN KEY (`kleur_kleurCode`) REFERENCES `kleur` (`kleurCode`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `instellingen`
--

INSERT INTO `instellingen` VALUES (1,'2017-06-02 11:23:54','Lander','0099ff');

--
-- Table structure for table `kleur`
--

CREATE TABLE `kleur` (
  `kleurCode` varchar(8) NOT NULL,
  `Naam` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`kleurCode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `kleur`
--

INSERT INTO `kleur` VALUES ('0099ff','blauw'),('d9d9d9','lichtgrijs'),('ff3300','rood'),('ffcc66','lichtoranje');

--
-- Table structure for table `meetmethoden`
--

CREATE TABLE `meetmethoden` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Methode` varchar(45) NOT NULL,
  `Eenheid` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `meetmethoden`
--

INSERT INTO `meetmethoden` VALUES (1,'temperatuur','°C'),(2,'vochtigheid','%'),(3,'luchtdruk','hPa'),(4,'windsnelheid','km/u');

--
-- Table structure for table `melding`
--

CREATE TABLE `melding` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Naam` varchar(55) NOT NULL,
  `Beschrijving` varchar(255) DEFAULT NULL,
  `TriggerWaarde` decimal(6,4) NOT NULL,
  `grens_ID` int(11) NOT NULL,
  `meetmethoden_ID` int(11) NOT NULL,
  `instellingen_ID` int(11) NOT NULL,
  `instellingen_gebruiker_Login` varchar(55) NOT NULL,
  PRIMARY KEY (`ID`,`grens_ID`,`meetmethoden_ID`,`instellingen_ID`,`instellingen_gebruiker_Login`),
  KEY `fk_melding_grens1_idx` (`grens_ID`),
  KEY `fk_melding_meetmethoden1_idx` (`meetmethoden_ID`),
  KEY `fk_melding_instellingen1_idx` (`instellingen_ID`,`instellingen_gebruiker_Login`),
  CONSTRAINT `fk_melding_grens1` FOREIGN KEY (`grens_ID`) REFERENCES `grens` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_melding_instellingen1` FOREIGN KEY (`instellingen_ID`, `instellingen_gebruiker_Login`) REFERENCES `instellingen` (`ID`, `gebruiker_Login`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_melding_meetmethoden1` FOREIGN KEY (`meetmethoden_ID`) REFERENCES `meetmethoden` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `melding`
--

INSERT INTO `melding` VALUES (1,'vries','temperatuur onder de 0 graden',0.0000,2,1,1,'Lander');

--
-- Table structure for table `meting`
--

CREATE TABLE `meting` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Tijd` datetime NOT NULL,
  `Temperatuur` decimal(4,2) DEFAULT NULL,
  `Vochtigheid` decimal(4,2) DEFAULT NULL,
  `Luchtdruk` decimal(6,2) DEFAULT NULL,
  `Windsnelheid` decimal(6,2) DEFAULT NULL,
  `weerstation_ID` int(11) NOT NULL,
  `weerstation_plaats_ID` int(11) NOT NULL,
  PRIMARY KEY (`ID`,`weerstation_ID`,`weerstation_plaats_ID`),
  KEY `fk_meting_weerstation1_idx` (`weerstation_ID`,`weerstation_plaats_ID`),
  CONSTRAINT `fk_meting_weerstation1` FOREIGN KEY (`weerstation_ID`, `weerstation_plaats_ID`) REFERENCES `weerstation` (`ID`, `plaats_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `meting`
--

INSERT INTO `meting` VALUES (4,'2017-06-02 11:30:14',25.60,5.10,1017.40,6.00,1,2);

--
-- Table structure for table `plaats`
--

CREATE TABLE `plaats` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Plaats` varchar(55) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `plaats`
--

INSERT INTO `plaats` VALUES (1,'Gent Dampoort'),(2,'Laarne Dorp');

--
-- Table structure for table `weerstation`
--

CREATE TABLE `weerstation` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Naam` varchar(45) NOT NULL,
  `DatumActief` datetime NOT NULL,
  `plaats_ID` int(11) NOT NULL,
  PRIMARY KEY (`ID`,`plaats_ID`),
  KEY `fk_weerstation_plaats_idx` (`plaats_ID`),
  CONSTRAINT `fk_weerstation_plaats` FOREIGN KEY (`plaats_ID`) REFERENCES `plaats` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `weerstation`
--

INSERT INTO `weerstation` VALUES (1,'Vogelkastje Station','2017-06-02 11:30:11',2);

--
-- Dumping events for database 'db_weerstation'
--

--
-- Dumping routines for database 'db_weerstation'
--


