Rails - 单表继承或不适用于申请人/员工关系

发布于 2024-11-02 10:44:20 字数 261 浏览 0 评论 0原文

我正在开发一个招聘应用程序,用于存储参加面试的人的记录。所以我有两个模型 - 申请人和申请人员工看起来像是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橙幽之幻 2024-11-09 10:44:20

根据我个人的观点,从面向对象的角度来看,你是正确的。

Applicant < Person

Employee < Person

但是,当涉及到数据库/表时,我将选择一个名为“人员”(人员)的表,该表包含“申请人”和“雇员”的所有列,并且有一列带有指示该人是否是申请人的标志或员工

才是正确的

注意::但这仅当您只有“几个其他字段”而不是很多HTH

Sameera 时

As per my personal opinion , in OO point of view you are correct.

Applicant < Person

Employee < Person

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文