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 |