ํ ์ด๋ธ ์ค๊ณ ๋ฐฉ์
- JPA๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ์ฒ์์๋ JPA์
ddl-auto
๊ธฐ๋ฅ์ ์ด์ฉํ์ฌ ๊ตฌํํจ
- ๊ตฌ์ฒด์ ์ธ ๊ฐ๋ฐ์ ์งํํ๋ฉด์, ์ต๋๊ฐ,
unique
,nullable
๋ฑ ์ฃผ์ ์ ์ฝ์ฌํญ์ ์ถ๊ฐํจ - ๋ฐ์ผ๋ฆฌ ์คํฌ๋ผ ์๊ฐ์ ํนํ ์ด์ฉ
- ์ผ์ ์ด์ ๊ฐ๋ฐ์ด ์งํ๋ ์ดํ
schema.sql
ํ์ผ ์ด์ฉํ์ฌ ํ ์ด๋ธ ๊ท์ , ์ด ์์ ์์ddl-auto
์ฌ์ฉ ์ค์ง
์ฌ์ ์ค๋นํด์จ ERD
์ปค๋ฎค๋ํฐ
๋ฏผ์ฑ(์ด๋ฏธ์ง ๋ฐฑ์
)
erDiagram card_collection ||--|{ card : have card_collection { bigint id PK bigint author_id FK int visit_count int scrap_count int residence int space int size int style int color boolean self string total_keywords } card { bigint collection_id FK string content int order string image_url string keywords }
ํ๋น
- ์ง๋ค์ด
- ๊ณ ๋ คํ ๋งํ ์ฌ์
@์์ด๋
ํํ์ ํ๊ทธ ๊ตฌํ- ์ฐ๊ฒฐ ํ
์ด๋ธ์ ์ด์ฉํด
@ManyToMany
๋ก ํ๋ฉด ์ด๋จ์ง?
- ํ๋ก์
- ์ฌ๊ท์ ๋ค๋๋ค ๊ด๊ณ์ ์ค๊ฐ ํ ์ด๋ธ
erDiagram COMMON { TIMESTAMP created_time TIMESTAMP modified_time } USER ||--o{ POST : have USER ||--o{ COMMENT : have USER ||--o{ FOLLOW : have USER { Long user_id PK VARCHAR nickname } FOLLOW { Long user_id PK Long target_id FK } POST ||--o{ COMMENT : have POST { Long post_id PK Long user_id FK "user_id of the USER" VARCHAR home_type INT home_size VARCHAR family_type VARCHAR city VARCHAR style INT budget VARCHAR title CLOB contents INT shared_times } COMMENT ||--o{ COMMENT : have COMMENT { Long comment_id PK Long user_id FK Long post_id FK Long parent_post_id FK "์์ ๋๊ธ์ post_id" VARCHAR comment }
- card_collection: ๊ทธ๋ฆผ ๊ด๋ จ
- ์ฌ์ง ๊ณ ์ id, ์์น
- ํด์ํ๊ทธ ์ฒ๋ฆฌ ๋ฌธ์
- ์นดํ ๊ณ ๋ฆฌ๋ redis ์บ์์ ์ ์ฅ
์ปค๋จธ์ค
ํ๊ธฐ

๋ฏผ์ฌ

ํ์
ํ์
์ปค๋ฎค๋ํฐ

์ปค๋จธ์ค

๋๋๊ธ์ ๊ตฌํํ ๊ฒ์ธ์ง?
์นดํ
๊ณ ๋ฆฌ์ ์ ๋
ํฌ์คํธ ํ
์ด๋ธ์ ๋๋๋ ์ ๋
ํตํฉ ERD
์ปค๋ฎค๋ํฐ ํํธ
- ๋ค์ด์ด๊ทธ๋จ
erDiagram base_entity { LocalDateTime created_at LocalDateTime updated_at } users ||--o{ follow: have users { bigint id PK varchar nickname varchar email varchar address varchar profile_image bigint following_count bigint follower_count } follow { bigint id PK bigint following_user_id FK bigint follower_user_id FK } users ||--o{ question : have question { bigint id PK bigint author_id FK varchar content int count } question ||--o{ question_image : have question_image { bigint id PK bigint question_id FK varchar image_url bigint order } users ||--o{ question_comment : have question ||--o{ question_comment : have question_comment { bigint id PK bigint author_id FK bigint question_id FK varchar content } users ||--o{ question_comment_reply : have question_comment ||--O{ question_comment_reply : have question_comment_reply { bigint id PK bigint author_id FK bigint comment_id FK varchar content } question ||--o{ question_keyword : have question_keyword { bigint id PK varchar name varchar category } question ||--o{ q_qk_link : have question_keyword ||--o{ q_qk_link : have q_qk_link { bigint id PK bigint question_id FK bigint keyword_id FK } users ||--o{ post : have post ||--o{ post_image : have post ||--o{ post_comment : have post_comment ||--o{ post_comment_reply : have post { bigint id PK bigint user_id FK varchar title varchar content int visit_count int scrap_count bigint writer bigint residence bigint area bigint budget bigint family bigint style bigint color_main bigint color_wall bigint color_floor bigint construction bigint expertise bigint agent } post_image { bigint id PK bigint post_id FK varchar url bigint order } post_comment { bigint id PK bigint post_id FK bigint author_id FK varchar title varchar content } post_comment_reply { bigint id PK bigint post_comment_id FK bigint author_id FK varchar title varchar content } user ||--o{ scrap_post : have post ||--o{ scrap_post : have scrap_post { bigint id PK bigint user_id FK bigint post_id FK }
- ๋ด์ฉ
์ปค๋จธ์ค
- ๋ค์ด์ด๊ทธ๋จ
erDiagram users ||--o{ review: have users ||--o{ product: have users ||--o{ question: have users ||--|| cart: have users { bigint id PK } review { bigint id PK bigint product_id FK bigint user_id FK int durability_point int price_point int design_poin int shipping_point varchar contents int help_point } question { bigint id PK bigint product_id FK bigint user_id FK varchar purchase_status varchar contents } seller { bigint id PK bigint user_id FK varchar seller_name } product ||--o{ review: have product ||--o{ question: have product ||--|{ order_item: have product ||--|{ cart_product: have product { bigint id PK bigint category_id FK bigint attribute_id FK varchar name bigint price varchar contents int views } attribute ||--|{ product: have attribute { bigint id PK varchar color varchar size varchar brand varchar shipping } category ||--|{ product: have category { bigint id PK varchar root_category varchar second_category varchar third_category varchar fourth_category } delivery { bigint id PK bigint order_id FK varchar delivery_status varchar address LocalDate delivery_date } orders ||--|| delivery: have orders ||--|{ order_item: have orders { bigint id PK bigint customer_id FK bigint total_price } cart_product { bigint id PK bigint cart_id FK bigint product_id FK } order_item { bigint id PK bigint order_id FK bigint product_id FK bigint cart_id FK bigint quantity bigint price } cart ||--o{ cart_item: have cart { bigint id PK varchar user_id FK } item_scrap { bigint id PK bigint user_id bigint product_id } category |o--o{ category: have category { bigint id PK bigint parent_id FK } review_image { }
- ๋ด์ฉ
ํตํฉ ๋ฒ์
- ๋ค์ด์ด๊ทธ๋จ
erDiagram base_entity { LocalDateTime created_at LocalDateTime updated_at } users ||--o{ follow: have users ||--o{ review: have users ||--o{ product: have users ||--o{ question: have users ||--|| cart: have users { bigint id PK varchar nickname varchar email varchar address varchar profile_image bigint following_count bigint follower_count } follow { bigint id PK bigint following_user_id FK bigint follower_user_id FK } users ||--o{ question : have question { bigint id PK bigint author_id FK varchar content int count } question ||--o{ question_image : have question_image { bigint id PK bigint question_id FK varchar image_url bigint order } users ||--o{ question_comment : have question ||--o{ question_comment : have question_comment { bigint id PK bigint author_id FK bigint question_id FK varchar content } users ||--o{ question_comment_reply : have question_comment ||--O{ question_comment_reply : have question_comment_reply { bigint id PK bigint author_id FK varchar content } question ||--o{ question_keyword : have question_keyword { bigint id PK varchar name varchar category } question ||--o{ q_qk_link : have question_keyword ||--o{ q_qk_link : have q_qk_link { bigint id PK bigint question_id FK bigint keyword_id FK } users ||--o{ post : have post ||--o{ post_image : have post ||--o{ post_comment : have post { bigint id PK bigint user_id FK varchar title varchar content int visit_count int scrap_count bigint writer bigint residence bigint area bigint budget bigint family bigint style bigint color_main bigint color_wall bigint color_floor bigint construction bigint expertise bigint agent } post_image { bigint id PK bigint post_id FK varchar url bigint order } post_comment { bigint id PK bigint post_id FK bigint author_id FK varchar title varchar content } users ||--o{ scrap_post : have post ||--o{ scrap_post : have scrap_post { bigint id PK bigint user_id FK bigint post_id FK } review { bigint id PK bigint product_id FK bigint user_id FK int durability_point int price_point int design_poin int shipping_point varchar contents int help_point } question { bigint id PK bigint product_id FK bigint user_id FK varchar purchase_status varchar contents } seller { bigint id PK bigint user_id FK varchar seller_name } product ||--o{ review: have product ||--o{ question: have product ||--|{ order_item: have product ||--|{ cart_item: have product ||--|{ seller: have product { bigint id PK varchar name bigint price varchar contents } delivery { bigint id PK bigint order_id FK varchar delivery_status varchar address LocalDate delivery_date } orders ||--|| delivery: have orders ||--|{ order_item: have orders { bigint id PK bigint customer_id FK bigint total_price } cart_item { bigint id PK bigint cart_id FK bigint product_id FK } order_item { bigint id PK bigint order_id FK bigint product_id FK bigint cart_id FK bigint quantity bigint price } cart ||--o{ cart_item: have cart { bigint id PK varchar user_id FK } item_scrap { bigint id PK bigint user_id bigint product_id } category |o--o{ category: have category { bigint id PK bigint parent_id FK } review_image { }
- ์ค๋ช