최종model.sql
4.96 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- 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 mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
-- -----------------------------------------------------
-- Schema os_prj01
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema os_prj01
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `os_prj01` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`calinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`calinfo` (
`CalTotal` VARCHAR(45) NOT NULL,
`UserNo` INT(11) NOT NULL,
`ConsumeDate` DATETIME NOT NULL,
`CalNo` INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`CalNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `mydb`.`consumeinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`consumeinfo` (
`ConsumeNo` INT(11) NOT NULL,
`ConsumeDetail` VARCHAR(45) NOT NULL,
`ConsumeDate` DATETIME NOT NULL,
`UserInfo_UserId` INT(11) NOT NULL,
PRIMARY KEY (`ConsumeNo`),
INDEX `fk_ConsumeInfo_UserInfo_idx` (`UserInfo_UserId` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `mydb`.`userinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`userinfo` (
`UserNo` VARCHAR(45) NOT NULL,
`UserID` VARCHAR(10) NOT NULL,
`UserPW` VARCHAR(45) NOT NULL,
`UserName` VARCHAR(45) NOT NULL,
`UserHeight` INT(11) NOT NULL,
`UserWeight` INT(11) NOT NULL,
`UserGender` TINYINT(4) NOT NULL,
`UserAge` INT(11) NOT NULL,
PRIMARY KEY (`UserNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
USE `os_prj01` ;
-- -----------------------------------------------------
-- Table `os_prj01`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`user` (
`UserID` VARCHAR(20) NOT NULL,
`UserPw` VARCHAR(45) NOT NULL,
`UserNo` INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`UserNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `os_prj01`.`caltable`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`caltable` (
`idCalTable` INT(11) NOT NULL AUTO_INCREMENT,
`CalTotal` INT(11) NOT NULL,
`CalLeftover` INT(11) NOT NULL,
`CalUserNo` VARCHAR(45) NOT NULL,
`user_UserNo` INT(11) NOT NULL,
PRIMARY KEY (`idCalTable`, `user_UserNo`),
INDEX `fk_caltable_user1_idx` (`user_UserNo` ASC) VISIBLE,
CONSTRAINT `fk_caltable_user1`
FOREIGN KEY (`user_UserNo`)
REFERENCES `os_prj01`.`user` (`UserNo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 2
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `os_prj01`.`consume`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`consume` (
`ConsumeNo` INT(11) NOT NULL AUTO_INCREMENT,
`ConsumeDate` DATETIME NOT NULL,
`ConsumeDetail` VARCHAR(45) NOT NULL,
`user_UserNo` INT(11) NOT NULL,
PRIMARY KEY (`ConsumeNo`),
INDEX `fk_consume_user1_idx` (`user_UserNo` ASC) VISIBLE,
CONSTRAINT `fk_consume_user1`
FOREIGN KEY (`user_UserNo`)
REFERENCES `os_prj01`.`user` (`UserNo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `os_prj01`.`userinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`userinfo` (
`UserHeight` INT(11) NOT NULL,
`UserWeight` INT(11) NOT NULL,
`UserAge` INT(11) NOT NULL,
`UserGender` TINYINT(4) NOT NULL,
`user_UserNo` INT(11) NOT NULL,
PRIMARY KEY (`user_UserNo`),
INDEX `fk_userinfo_user_idx` (`user_UserNo` ASC) VISIBLE,
CONSTRAINT `fk_userinfo_user`
FOREIGN KEY (`user_UserNo`)
REFERENCES `os_prj01`.`user` (`UserNo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;