-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodeNote.sql
106 lines (83 loc) · 3.44 KB
/
NodeNote.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- MySQL Script generated by MySQL Workbench
-- Fri Oct 5 11:48:08 2018
-- 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 NodeNote
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema NodeNote
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `NodeNote` DEFAULT CHARACTER SET utf8 ;
USE `NodeNote` ;
-- -----------------------------------------------------
-- Table `NodeNote`.`Users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `NodeNote`.`Users` ;
CREATE TABLE IF NOT EXISTS `NodeNote`.`Users` (
`User_id` VARCHAR(36) NOT NULL,
`email` VARCHAR(45) NOT NULL,
PRIMARY KEY (`User_id`))
ENGINE = InnoDB;
CREATE UNIQUE INDEX `User_id_UNIQUE` ON `NodeNote`.`Users` (`User_id` ASC) VISIBLE;
CREATE UNIQUE INDEX `email_UNIQUE` ON `NodeNote`.`Users` (`email` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `NodeNote`.`Lists`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `NodeNote`.`Lists` ;
CREATE TABLE IF NOT EXISTS `NodeNote`.`Lists` (
`List_id` INT NOT NULL AUTO_INCREMENT,
`User_id` VARCHAR(32) NOT NULL,
`Name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`List_id`),
CONSTRAINT `User_id1`
FOREIGN KEY (`User_id`)
REFERENCES `NodeNote`.`Users` (`User_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE UNIQUE INDEX `List_id_UNIQUE` ON `NodeNote`.`Lists` (`List_id` ASC) VISIBLE;
CREATE INDEX `User_id_idx` ON `NodeNote`.`Lists` (`User_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `NodeNote`.`Items`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `NodeNote`.`Items` ;
CREATE TABLE IF NOT EXISTS `NodeNote`.`Items` (
`Item_id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(45) NOT NULL,
`Completed` TINYINT(1) NOT NULL DEFAULT 0,
`List_id` INT NOT NULL,
PRIMARY KEY (`Item_id`),
CONSTRAINT `List_id1`
FOREIGN KEY (`List_id`)
REFERENCES `NodeNote`.`Lists` (`List_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `List_id_idx` ON `NodeNote`.`Items` (`List_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `NodeNote`.`UserLists`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `NodeNote`.`UserLists` ;
CREATE TABLE IF NOT EXISTS `NodeNote`.`UserLists` (
`UserId` VARCHAR(32) NOT NULL,
`ListId` INT NOT NULL,
CONSTRAINT `User_Id2`
FOREIGN KEY (`UserId`)
REFERENCES `NodeNote`.`Users` (`User_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `List_Id2`
FOREIGN KEY (`ListId`)
REFERENCES `NodeNote`.`Lists` (`List_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `User_Id_idx` ON `NodeNote`.`UserLists` (`UserId` ASC) VISIBLE;
CREATE INDEX `List_Id_idx` ON `NodeNote`.`UserLists` (`ListId` ASC) VISIBLE;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;