Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

부분 주문의 경우, 사용자가 요청한 주문 수량과 실제 주문 처리 수량이 다른데, 어떻게 주문 수량을 관리할 것인가? #115

Open
daadaadaah opened this issue Jul 8, 2023 · 0 comments

Comments

@daadaadaah
Copy link
Collaborator

daadaadaah commented Jul 8, 2023

Conclusion

  • v3 테이블 형태로 Go 🚀

v3 : order(original_order_quantity_for_partial_order+real_order_quantity)

CREATE TABLE `order` (
   # ...생략
  `original_order_quantity_for_partial_order` int NULL COMMENT '부분 주문 수량인 경우, 사용자가 요청한 주문 수량',
  `real_order_quantity` int NOT NULL COMMENT '실제 주문 처리 주문 수량',
   # ...생략
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

v1 : order(real_order_quantity)+partial_order(user_order_quantity)

CREATE TABLE `order` (
   # ... 생략
  `real_order_quantity` int NOT NULL COMMENT '실제 주문 처리 수량',
   # ...생략
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `partial_order` (
  `uuid` binary(16) PRIMARY KEY NOT NULL COMMENT '부분 주문 식별자',
  `order_uuid` binary(16) NOT NULL COMMENT '주문 식별자',
  `user_order_quantity` int NOT NULL COMMENT '사용자가 요청한 주문 수량',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_at` timestamp,
  `deleted_at` timestamp
)

v2 : order(user_order_quantity+real_order_quantity)

CREATE TABLE `order` (
   # ...생략
  `user_order_quantity` int NOT NULL COMMENT '사용자 요청 주문 수량',
  `real_order_quantity` int NOT NULL COMMENT '실제 주문 처리 주문 수량',
   # ...생략
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Why

이유 1. v1보다 애플리케이션 코드 및 쿼리 작성을 단순화시킬 수 있다는 점
이유 2. v2처럼 불필요하게 데이터가 중복되어 저장되지 않게 할 수 있다는 점

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant