在这种情况下可以使用STI吗?

发布于 2024-12-12 22:36:23 字数 263 浏览 6 评论 0原文

我有一个名为 people 的表 每个可以是客户经理会计师或三者的任意组合。 除了 people 表中的列之外,它们每个都有特殊的表列。

我现在正在做的是在每个表中使用 person_id...但我认为仅使用同一个表并为每个表使用不同的模型会更简单,所以我可以单独管理它们。

我应该这样做吗?

I have a table named people
Each person can be a client, a manager, an accountant, or any combination of the three.
Also each of them have special table columns, besides the ones in the people table.

What I'm doing now is using a person_id in each of the tables... but I think it would be much simpler to just used the same table, and a different model for each one, so I can manage them separately.

Should I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

没︽人懂的悲伤 2024-12-19 22:36:23

你没有一个很好的继承层次结构,所以我认为 STI 不适用。例如,就(单一)继承而言,您如何代表既是经理又是会计师的人?

如果一个人只能扮演这三种角色中的一种,那么性传播感染也许是有意义的;但即便如此,使用继承来实现角色应该会在您的脑海中敲响警钟,您应该知道一个人迟早会需要多个角色(并且可能在交付后立即成为一种关键必需品)。

You don't have a nice inheritance hierarchy so I don't think STI applies. For example, how would you represent a person that was both a manager and an accountant in terms of (single) inheritance?

If a person could only have one of the three roles then maybe STI would make sense; but even then implementing roles using inheritance should be setting off warning bells in your head, you should know that one person will end up needing multiple roles sooner or later (and it will probably become a critical necessity immediately after delivery).

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