๐Ÿ—๏ธ

ERD

์ผ์‹œ
Jun 17, 2022

ํ…Œ์ด๋ธ” ์„ค๊ณ„ ๋ฐฉ์‹

  • 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 ์บ์‹œ์— ์ €์žฅ

์ปค๋จธ์Šค

ํ›ˆ๊ธฐ

notion image

๋ฏผ์žฌ

notion image

ํšŒ์›

ํ˜„์ •

์ปค๋ฎค๋‹ˆํ‹ฐ
notion image
 
์ปค๋จธ์Šค
notion image
๋Œ€๋Œ“๊ธ€์„ ๊ตฌํ˜„ํ•  ๊ฒƒ์ธ์ง€?
์นดํ…Œ๊ณ ๋ฆฌ์˜ ์ •๋„
ํฌ์ŠคํŠธ ํ…Œ์ด๋ธ”์„ ๋‚˜๋ˆ„๋Š” ์ •๋„

ํ†ตํ•ฉ 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 { }
  • ์„ค๋ช