【发布时间】:2014-01-09 22:04:38
【问题描述】:
通过雇佣和面试的方式联系个人和公司是不好的做法吗? 为什么,具体来说? 这个答案是否适用于一般的数据库,而不仅仅是 Rails?
例子:
就业.rb
class Employment < ActiveRecord::Base
belongs_to :people
belongs_to :companies
end
interview.rb
class Interview < ActiveRecord::Base
belongs_to :people
belongs_to :companies
end
person.rb
class Person < ActiveRecord::Base
has_many :employments
has_many :interviews
has_many :companies, through: :employments
has_many :companies, through: :interviews
end
公司.rb
class Company < ActiveRecord::Base
has_many :employments
has_many :interviews
has_many :companies, through: :employments
has_many :companies, through: :interviews
end
个人和公司通过雇佣联系起来,但也通过面试冗余。
【问题讨论】:
标签: sql ruby-on-rails database associations