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

More than 3 years have passed since last update.

個人アプリ開発日記 #2

Posted at

基本的なテーブル構造

users テーブル

Column Type Options
nickname string null: false
email string null: false, unique: true
password_digest string null: false
remember_digest string
reset_digest string
activation_digest string null: false
activated boolean default: false
activated_ad datetime null: false

Association

  • has_many :drinks
  • has_many :comments
  • has_many :trades

drinks テーブル

coffeeは不可算名刺なので初心者が扱うのが怖かった、、

Column Type Options
name string null: false
price integer null: false
explain text null: false
user_id integer null: false,foreign_key: true

Association

  • belongs_to :user
  • has_many :comments
  • has_many :tags,
  • has_many :tags,through: :coffee_tags
  • has_one :trade

tags テーブル

Column Type Options
name string null: false
  • has_many :drinks
  • has_many :tags,through: :coffee_tags

coffee_tags テーブル

Column Type Options
drink_id integer null: false,foreign_key: true
tag_id integer null: false,foreign_key: true
  • belongs_to :drink
  • belongs_to :tag

comments テーブル

Column Type Options
content text null: false
user_id integer null: false,foreign_key: true
drink_id integer null: false,foreign_key: true

Association

  • belongs_to :user
  • belongs_to :drink

addresses テーブル

Column Type Options
postal_code string null: false
prefecture_id integer null: false
city string null: false
house_num string null: false
building_name string
phone_num string null:false,unique: true
trade_id integer null:false,foreign_key: true

Association

  • belongs_to :trade

trades テーブル

Column Type Options
user_id integer null: false,foreign_key: true
drink_id integer null: false,foreign_key: true

Association

  • belongs_to :user
  • belongs_to :drink
  • has_one :address

次回は実際のコードに触れていきます

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