Code Monkey home page Code Monkey logo

Comments (6)

maketheworldwise avatar maketheworldwise commented on June 4, 2024 1

1. store_in_requests

stores, store_in_requests 테이블을 나누신 이유가 있으신까요?
큰 이유가 없다면 store_status 컬럼 하나로도 충분히 관리가 가능해보입니다.

2. orders

orders, order_products 테이블을 나누신 이유가 있으신가요?
1번과 마찬가지로 큰 이유가 없다면 하나의 테이블로 관리가 가능할 것 같습니다.

3. store

store와 product 테이블의 1:N 관계 표현이 잘못된것 같습니다.

Table products {
  id long [pk, increment]
  store_id long [ref: > stores.id] // 하나의 스토어는 여러 개의 제품을 가진다.
  // (생략)
}

2. events

event와 products 테이블의 N:1 관계 표현이 잘못된것 같습니다.

추가로, 제품과 이벤트 테이블은 경우에 따라서 구조가 달라질 것 같습니다. 이 부분도 논의가 필요해보입니다.

제품 : 이벤트 = 1 : N

Table events {
  id long [pk, increment] // auto-increment
  product_id [ref: > [products.id](http://products.id/)]
  event_type varchar
  discount_rate float
  started_at timestamp
  ended_at timestamp
  created_at timestamp
  updated_at timestamp
}

제품 : 이벤트 = N : N

// event, product 관계 테이블
Table event_product_relation {
  id long [pk, increment] // auto-increment
  product_id [ref: > products.id]
  event_id [ref: > events.id]
}

3. categories (option)

카테고리가 텍스트로만 이루어져있어서 지금 구조로도 괜찮지만 별도의 테이블로 분리하는 것도 생각해보면 좋을 것 같습니다.
이 부분도 같이 생각해보시죠! 🤔

4. user_cart

장바구니의 경우에는 user와 product의 관계 테이블 하나만 있으면 될 것 같은데 혹시 고려하시는 내용이 있으신가요?

Table user_cart {
  id long [pk, increment] // auto-increment
  user_id long [ref: - users.id]
  product_id long [ref: - [products.id](http://products.id/)]
  created_at timestamp
  updated_at timestamp
}

from yousinsa.

NamKey avatar NamKey commented on June 4, 2024 1
  1. 과도하게 정규화를 한거 같네요 stores에 status 추가해서 진행하는 방향으로 하시죠

  2. many to many 관계를 중간테이블을 통해 풀었습니다. 1:N, N:1 로 관계를 설정하기 위해서 order_product - 중간 테이블을 생성했습니다.

  3. 맞습니다. 툴이 익숙치 않아서 반대로 했네요

  4. 초기 생각은 한 product에 하나의 event만 생각했는데 many-to-many 가시죠

  5. 동적으로 확장하는 설계도 고려해보았는데 catego�ry도(subcartegory는 추가가능) 동적으로 하면 기획이 더 커지기 때문에 줄였습니다.

  6. 정책에 따라 달라질 수 있긴한데 이렇게 가시죠!

from yousinsa.

NamKey avatar NamKey commented on June 4, 2024 1
  1. 해당사항 반영했습니다.
  2. 변경 없음
  3. 해당사항 반영했습니다.
  4. event와 product -> many-to-many
  5. 변경 없음
  6. 해당사항 반영했습니다.
  • User의 Role field를 추가했습니다. 마찬가지로 동적으로 role을 추가할 수 있지만 간소화하기 위해서 enum을 사용했습니다.

https://dbdiagram.io/d/626c11c695e7f23c619ca37d

// You can also define relaionship separately
// > many-to-one; < one-to-many; - one-to-one

Table users {
  id long [pk, increment] // auto-increment
  user_name varchar
  user_email varchar
  user_password_hash varchar
  user_role role
  created_at timestamp
  updated_at timestamp
}

Table stores {
  id long [pk, increment] // auto-increment
  store_name varchar
  store_owner long [ref: - users.id]
  store_status store_in_request_status
  created_at timestamp
  updated_at timestamp
}

Table products {
  id long [pk, increment] // auto-increment
  store_id long [ref: > stores.id] // many-to-one
  sub_category_id long [ref: > sub_categories.id] // many-to-one
  category category
  price int
  product_count int
  product_size varchar
  thumbnail_image_id long [ref: - product_detail_images.id]
  created_at timestamp
  updated_at timestamp
}

Table orders {
  id long [pk, increment] // auto-increment
  buyer_id long [ref: > users.id]
  order_status varchar
  created_at timestamp
  updated_at timestamp
}

Table order_products {
  id long [pk, increment] // auto-increment
  order_id long [ref: > orders.id]
  product_id long [ref: > products.id]
  buy_count int
  created_at timestamp
  updated_at timestamp
}

Table reviews {
  id long [pk, increment] // auto-increment
  product_id long [ref: > products.id]
  reviewer_id long [ref: > users.id]
  content text
  created_at timestamp
  updated_at timestamp
}

Table events {
  id long [pk, increment] // auto-increment
  event_type varchar
  discount_rate float
  started_at timestamp
  ended_at timestamp
  created_at timestamp
  updated_at timestamp
}

Table favorites {
  id long [pk, increment] // auto-increment
  product_id long [ref: - products.id]
  user_id long [ref: > users.id]
  created_at timestamp
}

Table product_detail_images {
  id long [pk, increment] // auto-increment
  product_id long [ref: > products.id]
  imagepath varchar
  created_at timestamp
  updated_at timestamp
}

Table sub_categories {
  id long [pk, increment] // auto-increment
  category_name varchar
  category category
  created_at timestamp
  updated_at timestamp
}

Table carts {
  id long [pk, increment] // auto-increment
  user_id long [ref: - users.id]
  product_id long [ref: < products.id]
  created_at timestamp
  updated_at timestamp
}

Table event_products {
  id long [pk, increment] // auto-increment
  product_id long [ref: > products.id] // many-to-one
  event_id long [ref: > events.id] // many-to-one
}

Enum category {
  TOP
  OUTER
  PANTS
}

Enum order_status {
  ORDERED
  PAID
  DELIVERING
  DELIVERED
}

Enum store_in_request_status {
  REQUESTED
  ACCEPTED
  REJECTED
  PENDING
}

Enum role {
  BUYER
  STORE_OWNER
  ADMIN
}

from yousinsa.

NamKey avatar NamKey commented on June 4, 2024

https://dbdiagram.io/d/626c11c695e7f23c619ca37d

  • Users

  • Stores

  • Products

  • Orders

  • Reviews

  • Events

  • Favorites

  • ProductImages

  • StoreInRequest

  • 장바구니에 대한 부분에 대한 논의가 필요합니다

@maketheworldwise

from yousinsa.

NamKey avatar NamKey commented on June 4, 2024

해당 툴에서 공동 수정하려면 프로 플랜이 필요해서 해당 스크립트도 첨부합니다

// You can also define relaionship separately
// > many-to-one; < one-to-many; - one-to-one

Table users {
  id long [pk, increment] // auto-increment
  user_name varchar
  user_email varchar
  user_password_hash varchar
  created_at timestamp
  updated_at timestamp
}

Table stores {
  id long [pk, increment] // auto-increment
  store_name varchar
  store_owner long [ref: - users.id]
  created_at timestamp
  updated_at timestamp
}

Table products {
  id long [pk, increment] // auto-increment
  store_id long [ref: < stores.id]
  category category
  sub_category long [ref: > sub_categories.id]
  price int
  product_count int
  product_size varchar
  event_id long [ref: < events.id]
  thumbnail_image_id long [ref: - product_detail_images.id]
  created_at timestamp
  updated_at timestamp
}

Table orders {
  id long [pk, increment] // auto-increment
  buyer_id long [ref: > users.id]
  order_status varchar
  created_at timestamp
  updated_at timestamp
}

Table order_products {
  id long [pk, increment] // auto-increment
  order_id long [ref: > orders.id]
  product_id long [ref: > products.id]
  buy_count int
  created_at timestamp
  updated_at timestamp
}

Table reviews {
  id long [pk, increment] // auto-increment
  product_id long [ref: > products.id]
  reviewer_id long [ref: > users.id]
  content text
  created_at timestamp
  updated_at timestamp
}

Table events {
  id long [pk, increment] // auto-increment
  event_type varchar
  discount_rate float
  started_at timestamp
  ended_at timestamp
  created_at timestamp
  updated_at timestamp
}

Table favorites {
  id long [pk, increment] // auto-increment
  product_id long [ref: - products.id]
  user_id long [ref: > users.id]
  created_at timestamp
}

Table product_detail_images {
  id long [pk, increment] // auto-increment
  product_id long [ref: > products.id]
  imagepath varchar
  created_at timestamp
  updated_at timestamp
}

Table store_in_request {
  id long [pk, increment] // auto-increment
  store_name varchar
  request_state varchar
  requester_id long [ref: - users.id]
  created_at timestamp
  updated_at timestamp
}

Table sub_categories {
  id long [pk, increment] // auto-increment
  category_name varchar
  category category
  created_at timestamp
  updated_at timestamp
}

Enum category {
  TOP
  OUTER
  PANTS
}

Enum order_status {
  ORDERED
  PAID
  DELIVERING
  DELIVERED
}

Enum store_in_request_status {
  REQUESTED
  ACCEPTED
  REJECTED
  PENDING
}

from yousinsa.

NamKey avatar NamKey commented on June 4, 2024

YOUSINSA

from yousinsa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.