私は、学生、従業員、保護者など、さまざまなタイプのユーザーがいるアプリケーションのデータモデルを設計しています。それぞれをPersonと呼びます。これらのエンティティごとに、エンティティ固有の情報を含む個別のテーブルがあります。login_id、passwordなどのユーザー固有の情報を含むusersテーブルがあります。usersテーブルの2つの列を使用して、UserとPersonの関係を確立しました。1。person_id integer 2. person_type integer
クラスの定義は次のとおりです。
class User < ActiveRecord :: Base
belongs_to :person, :polymorphic =>true, :dependent => :destory
end
class Student < ActiveRecord :: Base
has_one :user, :as => :person
end
class Parent < ActiveRecord :: Base
has_one :user, :as => :person
end
class Employee < ActiveRecord :: Base
has_one :user, :as => :person
end
このデザインについて貴重なコメントをお願いします。大丈夫ですか、それとも変更が必要ですか?