Rails - 单表继承或不适用于申请人/员工关系
我正在开发一个招聘应用程序,用于存储参加面试的人的记录。所以我有两个模型 - 申请人和申请人员工看起来像是 OO 意义上的员工。即员工之前是申请人。因此,我计划创建一个单表继承,例如:
Applicant <个人
雇员<人员
申请人的所有字段都在员工中。员工还有其他几个不在申请人中的字段。
我这个计划正确吗?我还有另一个类似的场景需要处理 - 前景和前景。客户。
更新:随着我越来越多地接触性病,我开始不喜欢它。
I am am developing a recruitment application for storing records of people who come for an interview. So I have two models - Applicant & Employee which seem like one in OO sense. i.e. Employee was earlier an applicant. Therefore I am planning to create a Single table inheritance like:
Applicant < Person
Employee < Person
All the fields of Applicant are there in Employee. Employee has several other fields that are not in Applicant.
Am I correct with this plan. I have another similar scenario to deal with - prospects & clients.
Update: As I am working more and more with STI, I am starting to dislike it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我个人的观点,从面向对象的角度来看,你是正确的。
但是,当涉及到数据库/表时,我将选择一个名为“人员”(人员)的表,该表包含“申请人”和“雇员”的所有列,并且有一列带有指示该人是否是申请人的标志或员工
才是正确的
注意::但这仅当您只有“几个其他字段”而不是很多HTH
Sameera 时
As per my personal opinion , in OO point of view you are correct.
But when it comes to database/ tables i will go for a one table called 'persons' (Person) that has all the columns for both 'Applicant' and 'Employee' and have a column with a flag indicating whether the Person is an Applicant or Employee
NOTE :: but this is only true if you have ONLY 'several other fields' not many
HTH
sameera