-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 데이터베이스 테이블명, 컬럼명 소문자로 변경, 외래키 제거
- Loading branch information
Showing
1 changed file
with
25 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
DROP TABLE IF EXISTS PRODUCT; | ||
DROP TABLE IF EXISTS DIARY_RECORD; | ||
DROP TABLE IF EXISTS DIARY; | ||
DROP TABLE IF EXISTS product; | ||
DROP TABLE IF EXISTS diary_record; | ||
DROP TABLE IF EXISTS diary; | ||
|
||
CREATE TABLE PRODUCT ( | ||
PRODUCT_ID BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
PRODUCT_NAME VARCHAR(255) NOT NULL, | ||
PRODUCT_CORP VARCHAR(255), | ||
PRODUCT_NORMALIZED_NAME VARCHAR(255) UNIQUE, | ||
NUTRITION_FACTS VARCHAR(255), | ||
MEMBER_ID BIGINT NOT NULL, | ||
CREATED_AT DATETIME NOT NULL, | ||
UPDATED_AT DATETIME NOT NULL | ||
CREATE TABLE product ( | ||
product_id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
product_name VARCHAR(255) NOT NULL, | ||
product_corp VARCHAR(255), | ||
product_normalized_name VARCHAR(255) UNIQUE, | ||
nutrition_facts VARCHAR(255), | ||
member_id BIGINT NOT NULL, | ||
created_at DATETIME NOT NULL, | ||
updated_at DATETIME NOT NULL | ||
); | ||
|
||
CREATE TABLE DIARY ( | ||
DIARY_ID BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
MEMBER_ID BIGINT NOT NULL, | ||
DIARY_DATE DATE NOT NULL, | ||
CONSTRAINT UC_DIARY_DATE UNIQUE (MEMBER_ID, DIARY_DATE) | ||
CREATE TABLE diary ( | ||
diary_id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
member_id BIGINT NOT NULL, | ||
diary_date DATE NOT NULL, | ||
CONSTRAINT uc_diary_date UNIQUE (member_id, diary_date) | ||
); | ||
|
||
CREATE TABLE DIARY_RECORD ( | ||
DIARY_RECORD_ID BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
DIARY_ID BIGINT, | ||
PRODUCT_ID BIGINT NOT NULL, | ||
MEAL_TYPE VARCHAR(255) NOT NULL, | ||
QUANTITY DECIMAL NOT NULL, | ||
CLIENT_CHOICE_SERVING_UNIT_DESCRIPTION VARCHAR(255), | ||
CALCULATED_NUTRITION VARCHAR(255), | ||
FOREIGN KEY (DIARY_ID) REFERENCES DIARY(DIARY_ID) | ||
CREATE TABLE diary_record ( | ||
diary_record_id BIGINT PRIMARY KEY AUTO_INCREMENT, | ||
diary_id BIGINT, | ||
product_id BIGINT NOT NULL, | ||
meal_type VARCHAR(255) NOT NULL, | ||
quantity DECIMAL NOT NULL, | ||
client_choice_serving_unit_description VARCHAR(255), | ||
calculated_nutrition VARCHAR(255) | ||
); | ||
|
||
|