-- MySQL Script generated by MySQL Workbench -- Thu 12 May 2016 08:03:04 PM EEST -- Model: New Model Version: 1.0 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='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Schema mydb -- ----------------------------------------------------- -- ----------------------------------------------------- -- Table `viewLogT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `viewLogT` ; CREATE TABLE IF NOT EXISTS `viewLogT` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeId` INT UNSIGNED NOT NULL, `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `addedDate` DATE NOT NULL, PRIMARY KEY (`id`), INDEX `fk_viewLogT_nodeT1_idx` (`nodeId` ASC), INDEX `addeddate_idx` (`addedDate` ASC), CONSTRAINT `fk_viewLogT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `viewStatDailyT` -- ----------------------------------------------------- DROP TABLE IF EXISTS `viewStatDailyT` ; CREATE TABLE IF NOT EXISTS `viewStatDailyT` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `nodeId` INT UNSIGNED NOT NULL, `statDate` DATE NOT NULL, `amount` INT UNSIGNED NOT NULL DEFAULT 0, `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `nodeid_statdate_uq` (`nodeId` ASC, `statDate` ASC), CONSTRAINT `fk_viewStatDailyT_nodeT1` FOREIGN KEY (`nodeId`) REFERENCES `nodeT` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;