0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ECサイトのテーブル設計

Posted at

ECサイト作成時のテーブル設計の一例を示す。

商品テーブル

概要 カラム名 制約
PK id not null
name string, not null
price integer, not null
description string, not null
deleted boolean

カートテーブル(carts)

概要 カラム名 制約
PK id not null

カート商品テーブル(cart_products)

概要 カラム名 制約
PK id not null
PK cart_id bigint, not null
FK product_id bigint, not null
FK quantity integer, not null

請求情報テーブル(billingInfos)

has_many :purchase_details

概要 カラム名 制約
PK id not null
first_name string, not null
last_name string, not null
user_name string, not null
email string, not null
address string, not null
address2 string,
country string, not null
state string, not null
zip string, not null
same_address_flag boolean, not null
save_info_flag boolean, not null
payment_method string, not null
name_on_card string, not null
credit_cart_number string, not null
credit_cart_expiration string, not null
credit_cart_cvv string, not null
discount_amount integer

購入明細テーブル(purchase_details)

belongs_to :billing_info

概要 カラム名 制約
PK id not null
FK billing_info_id bigint, not null
FK product_id bigint, not null
quantity integer, not null

プロモーションコードテーブル(promotion_codes)

概要 カラム名 制約
PK id not null
promotion_code string, not null
discount_amount integer, not null

カートプロモーションコード

概要 カラム名 制約
PK id not null
cart_id integer, not null
promotion_code string, not null
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?