김태희

db

1 +-- MySQL Workbench Forward Engineering
2 +
3 +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
4 +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
5 +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';
6 +
7 +-- -----------------------------------------------------
8 +-- Schema mydb
9 +-- -----------------------------------------------------
10 +
11 +-- -----------------------------------------------------
12 +-- Schema mydb
13 +-- -----------------------------------------------------
14 +CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
15 +-- -----------------------------------------------------
16 +-- Schema os_prj01
17 +-- -----------------------------------------------------
18 +
19 +-- -----------------------------------------------------
20 +-- Schema os_prj01
21 +-- -----------------------------------------------------
22 +CREATE SCHEMA IF NOT EXISTS `os_prj01` DEFAULT CHARACTER SET utf8 ;
23 +USE `mydb` ;
24 +
25 +-- -----------------------------------------------------
26 +-- Table `mydb`.`calinfo`
27 +-- -----------------------------------------------------
28 +CREATE TABLE IF NOT EXISTS `mydb`.`calinfo` (
29 + `CalTotal` VARCHAR(45) NOT NULL,
30 + `UserNo` INT(11) NOT NULL,
31 + `ConsumeDate` DATETIME NOT NULL,
32 + `CalNo` INT(11) NOT NULL AUTO_INCREMENT,
33 + PRIMARY KEY (`CalNo`))
34 +ENGINE = InnoDB
35 +DEFAULT CHARACTER SET = utf8;
36 +
37 +
38 +-- -----------------------------------------------------
39 +-- Table `mydb`.`consumeinfo`
40 +-- -----------------------------------------------------
41 +CREATE TABLE IF NOT EXISTS `mydb`.`consumeinfo` (
42 + `ConsumeNo` INT(11) NOT NULL,
43 + `ConsumeDetail` VARCHAR(45) NOT NULL,
44 + `ConsumeDate` DATETIME NOT NULL,
45 + `UserInfo_UserId` INT(11) NOT NULL,
46 + PRIMARY KEY (`ConsumeNo`),
47 + INDEX `fk_ConsumeInfo_UserInfo_idx` (`UserInfo_UserId` ASC) VISIBLE)
48 +ENGINE = InnoDB
49 +DEFAULT CHARACTER SET = utf8;
50 +
51 +
52 +-- -----------------------------------------------------
53 +-- Table `mydb`.`userinfo`
54 +-- -----------------------------------------------------
55 +CREATE TABLE IF NOT EXISTS `mydb`.`userinfo` (
56 + `UserNo` VARCHAR(45) NOT NULL,
57 + `UserID` VARCHAR(10) NOT NULL,
58 + `UserPW` VARCHAR(45) NOT NULL,
59 + `UserName` VARCHAR(45) NOT NULL,
60 + `UserHeight` INT(11) NOT NULL,
61 + `UserWeight` INT(11) NOT NULL,
62 + `UserGender` TINYINT(4) NOT NULL,
63 + `UserAge` INT(11) NOT NULL,
64 + PRIMARY KEY (`UserNo`))
65 +ENGINE = InnoDB
66 +DEFAULT CHARACTER SET = utf8;
67 +
68 +USE `os_prj01` ;
69 +
70 +-- -----------------------------------------------------
71 +-- Table `os_prj01`.`user`
72 +-- -----------------------------------------------------
73 +CREATE TABLE IF NOT EXISTS `os_prj01`.`user` (
74 + `UserID` VARCHAR(20) NOT NULL,
75 + `UserPw` VARCHAR(45) NOT NULL,
76 + `UserNo` INT(11) NOT NULL AUTO_INCREMENT,
77 + PRIMARY KEY (`UserNo`))
78 +ENGINE = InnoDB
79 +DEFAULT CHARACTER SET = utf8;
80 +
81 +
82 +-- -----------------------------------------------------
83 +-- Table `os_prj01`.`caltable`
84 +-- -----------------------------------------------------
85 +CREATE TABLE IF NOT EXISTS `os_prj01`.`caltable` (
86 + `idCalTable` INT(11) NOT NULL AUTO_INCREMENT,
87 + `CalTotal` INT(11) NOT NULL,
88 + `CalLeftover` INT(11) NOT NULL,
89 + `CalUserNo` VARCHAR(45) NOT NULL,
90 + `user_UserNo` INT(11) NOT NULL,
91 + PRIMARY KEY (`idCalTable`, `user_UserNo`),
92 + INDEX `fk_caltable_user1_idx` (`user_UserNo` ASC) VISIBLE,
93 + CONSTRAINT `fk_caltable_user1`
94 + FOREIGN KEY (`user_UserNo`)
95 + REFERENCES `os_prj01`.`user` (`UserNo`)
96 + ON DELETE NO ACTION
97 + ON UPDATE NO ACTION)
98 +ENGINE = InnoDB
99 +AUTO_INCREMENT = 2
100 +DEFAULT CHARACTER SET = utf8;
101 +
102 +
103 +-- -----------------------------------------------------
104 +-- Table `os_prj01`.`consume`
105 +-- -----------------------------------------------------
106 +CREATE TABLE IF NOT EXISTS `os_prj01`.`consume` (
107 + `ConsumeNo` INT(11) NOT NULL AUTO_INCREMENT,
108 + `ConsumeDate` DATETIME NOT NULL,
109 + `ConsumeDetail` VARCHAR(45) NOT NULL,
110 + `user_UserNo` INT(11) NOT NULL,
111 + PRIMARY KEY (`ConsumeNo`),
112 + INDEX `fk_consume_user1_idx` (`user_UserNo` ASC) VISIBLE,
113 + CONSTRAINT `fk_consume_user1`
114 + FOREIGN KEY (`user_UserNo`)
115 + REFERENCES `os_prj01`.`user` (`UserNo`)
116 + ON DELETE NO ACTION
117 + ON UPDATE NO ACTION)
118 +ENGINE = InnoDB
119 +DEFAULT CHARACTER SET = utf8;
120 +
121 +
122 +-- -----------------------------------------------------
123 +-- Table `os_prj01`.`userinfo`
124 +-- -----------------------------------------------------
125 +CREATE TABLE IF NOT EXISTS `os_prj01`.`userinfo` (
126 + `UserHeight` INT(11) NOT NULL,
127 + `UserWeight` INT(11) NOT NULL,
128 + `UserAge` INT(11) NOT NULL,
129 + `UserGender` TINYINT(4) NOT NULL,
130 + `user_UserNo` INT(11) NOT NULL,
131 + PRIMARY KEY (`user_UserNo`),
132 + INDEX `fk_userinfo_user_idx` (`user_UserNo` ASC) VISIBLE,
133 + CONSTRAINT `fk_userinfo_user`
134 + FOREIGN KEY (`user_UserNo`)
135 + REFERENCES `os_prj01`.`user` (`UserNo`)
136 + ON DELETE NO ACTION
137 + ON UPDATE NO ACTION)
138 +ENGINE = InnoDB
139 +DEFAULT CHARACTER SET = utf8;
140 +
141 +
142 +SET SQL_MODE=@OLD_SQL_MODE;
143 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
144 +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;