Chat-Space DB設計 usersテーブル Column Type Options nickname string null: false email string null: false password string null: false Association has_many :messages has_many :group_users has_many :groups, through: :group_users groupsテーブル Column Type Options name string null: false Association has_many :messages has_many :group_users has_many :users, through: :group_users messageテーブル Column Type Options text text image user_id integer null: false, foreign_key: true group_id integer null: false, foreign_key: true Association belongs_to :user belongs_to :group group_usersテーブル Column Type Options user_id integer null: false, foreign_key: true group_id integer null: false, foreign_key: true Association belongs_to :user belongs_to :group