내배캠/프로젝트, 개인과제 코드&내용정리

[내일배움캠프/백엔드] Spring 심화 개인과제 Lv0. API 명세 및 ERD, SQL 작성하기

jy3574 2024. 11. 28. 23:30
API 명세서 작성

 

 

ERD 작성

SQL 작성
CREATE TABLE User (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(200) NOT NULL,
    email VARCHAR(200) NOT NULL UNIQUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE Currency (
    id INT AUTO_INCREMENT PRIMARY KEY,
    currency_name VARCHAR(200) NOT NULL,
    exchange_rate DECIMAL(10,2) NOT NULL,
    symbol VARCHAR(20) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE ExchangeRequest (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    currency_id INT NOT NULL,
    before_exchange DECIMAL(10,2) NOT NULL,
    after_exchange DECIMAL(10,2) NOT NULL,
    status VARCHAR(20) DEFAULT 'normal',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES User(id) ON DELETE CASCADE,
    FOREIGN KEY (currency_id) REFERENCES Currency(id)
);