0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[06.10編集]fleamarket_sample_72a DB設計

Last updated at Posted at 2020-06-04

チーム共有用

機能洗い出し

  • ユーザー新規登録/ログイン・ログアウト
  • 商品出品・購入
  • コメント
  • カテゴリー検索
  • マイページ/商品編集機能
  • クレジットカード登録・変更

ER図

DB設計

usersテーブル

Column Type Options
nickname string null: false
email string null: false, unique: true
password string null: false
family_name string null: false
first_name string null: false
family_name_kana string null: false
first_name_kana string null: false
birthday_year string null: false
birthday_month string null: false
birthday_day string null: false

Association

  • belongs_to :delivery_date dependent: :destroy
  • has_many :creditcards dependent: :destroy
  • has_many :comennts dependent: :destroy
  • has_many :products dependent: :destroy

delivery_datasテーブル

Column Type Options
family_name string null: false
first_name string null: false
family_name_kana string null: false
first_name_kana string null: false
zipcode integer null: false
prefecture string null: false
city string null: false
address string null: false
building integer
phone integer
user reference null: false, foreign_key: true

Association

  • belongs_to :user

productsテーブル

Column Type Options
name string null: false
comment text null: false
price integer null: false
brand string
size string
shippingcharge string null: false
area string null: false
days string null: false
user reference null: false, foreign_key: true
category reference null: false, foreign_key: true

Association

  • belongs_to :user dependent: :destroy
  • belongs_to :category dependent: :destroy
  • has_many :comments dependent: :destroy
  • has_many :images dependent: :destroy

categorysテーブル

Column Type Options
name string null: false

Association

  • has_many :products

commentsテーブル

Column Type Options
content text
user reference null: false, foreign_key: true
product reference null: false, foreign_key: true

Association

  • belongs_to :user
  • belongs_to :product

creditcardsテーブル

Column Type Options
user reference null: false, foreign_key: true
customer string null: false
card string null: false

Association

  • belongs_to :user

imagesテーブル

Column Type Options
image image null: false
product reference null: false, foreign_key: true

Association

  • belongs_to :product

補足

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?