实施“聚会模式”的正确方法是什么?各方扮演的各种角色?
我们正在开发的项目之一正在不断发展,我们正处于可以重新访问现有数据库并花时间“尝试使其正确”的阶段。我们正在研究的事情之一是数据模型以及我们如何对“各方”进行建模等。到目前为止,我们已经通过交易记录确定客户详细信息,但现在我们想要存储更多详细信息,并希望结合我们拥有的员工、供应商和会员等的通用数据。
每一方要么是个人,要么是团体,但也可以有一个或多个角色,例如雇主、客户、会员等。我意识到,如果没有与另一方的关系,我们模型中的各方就不存在(员工需要雇主,客户需要公司来购买来自,会员需要俱乐部等),因为我不想要人们添加诸如“雇主-客户”或“成员-分包商”之类的愚蠢关系,我现在有一个名为relationship
的表,它预定义了哪些角色可以相互配合。我以前没有见过这个,我想知道我们是否走在正确的道路上? (这是一个简化的 EER 图,以显示我们认为如何表示这一点)
我看过各种有关政党模型原则的文档,但我无法找到任何(开源)示例来说明它在实践中的实际情况。任何人都可以推荐一个源(最好是 MySQL 中的)或分享您如何实现它的经验,也许使用表结构或应用程序代码?
One of the programs we're working on is growing and we're at a stage where we can revisit the existing database and spend time 'trying to get it right'. One of the things we're looking at is the data model and how we model 'parties' among other things. We have made do until now with determining customer details from transaction records, but now we want to store more detail and would like to combine the common data we have for staff, suppliers and members, etc.
Each party is either an individual or a group, but can also have one or more roles such as employer, client, member, etc. I realise that various parties in our model don't exist without a relationship to another party (staff need an employer, a customer needs a company to buy from, members need a club, etc) and since I don't want people to add silly relationships like 'employer-client' or 'member-subcontractor', I now have a table called relationship
which predefines which roles can go with each other. I haven't seen this before and I wonder, are we on the right track? (Here is a simplified EER diagram to show how we think this might be represented)
I have looked at various documentation on the principles of the party model, but I haven't been able to find any (open source) examples of how it actually looks in pratice. Can anyone recommend a source (preferably in MySQL) or share your experience on how to implement it, perhaps with the table structure or application code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案< /a> 有各方的实施。
另一个答案,将此模式应用于文章和博客文章和故事,其中解释了一些评论中的微妙之处。
This SO answer has an implementation of parties.
Another answer, applying this pattern to articles and blog posts and stories has explanations of some of the subtle points in the comments.