Skip to content

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

@daadaadaah

Description

@daadaadaah

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions