
CREATE DATABASE  IF NOT EXISTS `opengarden`; 
USE `opengarden`; 


-- 
-- Table structure for table `measurements` 
-- 

DROP TABLE IF EXISTS `measurements`; 
CREATE TABLE `measurements` ( 
	  `_id` int(11) NOT NULL AUTO_INCREMENT, 
	  `node_id` int(11) NOT NULL, 
	  `sensor_type` varchar(45) NOT NULL, 
	  `value` varchar(45) NOT NULL, 
	  `date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, 
	  `unit` varchar(45) NOT NULL, 
	  `node_type` varchar(45) NOT NULL, 
	  PRIMARY KEY (`_id`), 
	  KEY `fk_node_id_idx` (`node_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Table structure for table `actuators` 
-- 

DROP TABLE IF EXISTS `actuators`; 
CREATE TABLE `actuators` ( 
	  `_id` int(11) NOT NULL AUTO_INCREMENT, 
	  `type` varchar(45) DEFAULT NULL, 
	  `state` tinyint(4) DEFAULT NULL, 
	  PRIMARY KEY (`_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8; 

INSERT INTO actuators VALUES (1, 'irrigation1', 0); 
INSERT INTO actuators VALUES (2, 'irrigation2', 0); 
INSERT INTO actuators VALUES (3, 'irrigation3', 0);

