-- MySQL Script generated by MySQL Workbench
-- Mon May 27 22:26:40 2019
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema solarweatherstation
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema solarweatherstation
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `solarweatherstation` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
USE `solarweatherstation` ;

-- -----------------------------------------------------
-- Table `solarweatherstation`.`soort_meting`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `solarweatherstation`.`soort_meting` (
  `Soort_id` INT(11) NOT NULL,
  `Soort` VARCHAR(45) NOT NULL,
  `Beschrijving` VARCHAR(45) NOT NULL,
  `Eenheid` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Soort_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `solarweatherstation`.`meting`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `solarweatherstation`.`meting` (
  `Meting_id` INT(11) NOT NULL AUTO_INCREMENT,
  `Waarde` FLOAT NOT NULL,
  `Tijd` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `soort_meting_id` INT(11) NOT NULL,
  PRIMARY KEY (`Meting_id`, `soort_meting_id`),
  INDEX `fk_meting_soort_meting_idx` (`soort_meting_id` ASC) VISIBLE,
  CONSTRAINT `fk_meting_soort_meting`
    FOREIGN KEY (`soort_meting_id`)
    REFERENCES `solarweatherstation`.`soort_meting` (`Soort_id`))
ENGINE = InnoDB
AUTO_INCREMENT = 2
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `solarweatherstation`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `solarweatherstation`.`users` (
  `User_id` INT(11) NOT NULL AUTO_INCREMENT,
  `Username` VARCHAR(45) NOT NULL,
  `Email` VARCHAR(45) NULL DEFAULT NULL,
  `Password` VARCHAR(45) NULL DEFAULT NULL,
  `Unit` VARCHAR(15) NULL DEFAULT 'metric',
  `Active` INT(11) NULL DEFAULT '0',
  PRIMARY KEY (`User_id`),
  UNIQUE INDEX `Username_UNIQUE` (`Username` ASC) VISIBLE,
  UNIQUE INDEX `Email_UNIQUE` (`Email` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
