实行“派对模式”的正确方法与各方发挥的各种作用是什么? [英] What is the correct way to implement a 'party model' with the various roles that parties play?

查看:520
本文介绍了实行“派对模式”的正确方法与各方发挥的各种作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力的一个程序正在增长,我们正处于一个阶段,我们可以重新访问现有的数据库,并花费时间试图让它正确。我们正在研究的事情之一是数据模型,以及我们如何模仿各方等等。直到现在,我们已经确定了交易记录中的客户详细信息,但现在我们想要存储更多的细节,并希望结合我们为员工,供应商和会员等提供的常见数据。



每个派对都是个人或团体,但也可以有一个或多个角色,如雇主,客户,成员等。我意识到我们的模型中的各方不存在,而没有关系另一方(工作人员需要雇主,客户需要一家公司购买,会员需要一个俱乐部等),而且由于我不希望人们添加像雇主客户或成员分包商这样的愚蠢的关系,我现在有一个名为关系的表,它预先定义了哪些角色可以相互交织。我以前没有看过这个,我想知道,我们在正确的轨道上吗? (这是一个简化的EER图,显示我们如何看待这可能被表示)





我已经看过了关于派对模式原理的各种文档,但是我还没有找到任何(开源)例子,它如何实际看起来在pratice。任何人都可以推荐一个源代码(最好在MySQL中),或者分享一下你的实践经验,也许是使用表格结构或应用程序代码?

解决方案>

这个SO答案有各方的实施。



另一个答案,将这种模式应用到文章和博客文章和故事中,对评论中的一些微妙点进行了解释。


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?

解决方案

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.

这篇关于实行“派对模式”的正确方法与各方发挥的各种作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆