图形建模布尔值-关系属性,还是节点属性,或者根本没有? [英] Graph Modeling boolean value - relationship property, or node property or none at all?

查看:157
本文介绍了图形建模布尔值-关系属性,还是节点属性,或者根本没有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

一家企业有很多合作伙伴.每个合作伙伴都可以为其客户提供多种服务.一些合作伙伴提供所有服务,一些提供一些.企业始终可以向该合作伙伴出售产品,可以出售哪种产品取决于合作伙伴是否提供特定服务.因此,企业可以将产品A出售给提供服务A的合作伙伴A.如果他们不提供服务B,则可以将产品B出售给合作伙伴A.

A business has many Partners. Each partner could offer multiple Services to their customers. Some Partners offer All Services, some offer a few. The business can always sell a Product to that Partner, and which Product can be sold depends on whether the Partner offers a particular Service or not. So business could sell Product A to Partner A offering Service A. They could offer Product B to Partner A if they don't offer Service B.

问题-如果合作伙伴,产品,服务是节点,我应该在哪里建模问题此合作伙伴提供此服务?"另一个业务问题是我对产品A的市场是什么? -应该返回所有不提供产品A内置服务的合作伙伴. 我应该这样做:

Question - if Partners, Products, Services are nodes, where should I model the question 'is this Service offered by this Partner?" Another business question would be "Whats my market for Product A?" - which should return all the Partners that don't offer the Service Built with Product A. Should I do:

  1. Partner_OFFERS_Service_BUILT_WITH_Product(仅具有 Partner_Service关系,其中Offered = yes).在这种情况下, 我会退还可以出售服务产品的合作伙伴吗? 他们还没有提供?
  2. Partner_COULD-OFFER_Service_BUILT_WITH_Product,并具有 以COULD_OFFER关系
  3. 的属性形式提供的是/是/否
  4. Partner_COULD-OFFER_Service_BUILT_WITH_Product,并具有 在节点Service上提供的属性为是/否".这将无法正常工作,因为我无法为每个合作伙伴都拥有此属性.
  5. 具有2种不同类型的关系-OFFERSDOESNT_OFFER至 将每个合作伙伴与每项服务相关联,但是要有一种机制来切换 如果采用率发生变化,则为亲戚关系.
  1. Partner_OFFERS_Service_BUILT_WITH_Product (only have Partner_Service relations where Offered=yes). In this case, how would i return the partners that could be sold a product for Service they don't yet offer?
  2. Partner_COULD-OFFER_Service_BUILT_WITH_Product,and have Offered=yes/no as a property on the COULD_OFFER relationship
  3. Partner_COULD-OFFER_Service_BUILT_WITH_Product, and have Offered=yes/no as a property on the node Service. This wouldn't work as I can't have this property for every partner.
  4. Have 2 different kinds of relationships - OFFERS and DOESNT_OFFER to relate every partner to every service, but then have a mechanism to switch the relationship if adoption changes.

这将是Spring Java应用程序的后端.我知道可以通过多种方式完成此操作,并尝试从查询和编码的角度理解实现此目的的最简单方法.

This will be the backend for a Spring Java application. I understand it could be done in multiple ways and trying to understand simplest way to do this from a query and coding perspective.

编辑与用户讨论后,要求变得更加复杂.他们实际所做的就像是关系世界中的表,其中包含以下各列 (通过大量重复数据进行了非规范化处理:

EDIT Having discussed with users, the requirement just got more complex. What they actually do is something like a table in relational world with following columns (its denormalised with lot of repetitive data:

PartnerName | Service | Offered? |CurrentlyUsing | WeCouldSellThese |

XX | Baking | Yes |Competitor A, B | Product A | XX | Baking | Yes |Competitor A, B | Product C | XX | Baking | Yes |Competitor A, B | Product D | XX | OnlyDough| Yes |Product A | Product C | XX | Packing | No | | Product E |

XX | Baking | Yes |Competitor A, B | Product A | XX | Baking | Yes |Competitor A, B | Product C | XX | Baking | Yes |Competitor A, B | Product D | XX | OnlyDough| Yes |Product A | Product C | XX | Packing | No | | Product E |

基本上,他们需要存储当前正在使用的信息,并且 不论其当前是否由合作伙伴提供,他们仍会尝试向其销售产品(提供是"或否"都将继续推向市场).服务与产品之间也存在多对多关系……这意味着存在"3node"关系-潜在客户定义为针对特定服务的特定产品的特定合作伙伴, 我已经尝试了以下模型,但是当单个产品上存在多个此类关系时,我不确定如何一起查询Could_Buy和To_Build.

Basically, they need to store information what is being used currently, and whether its currently offered by partner or not, they still try to sell them products (Offered Yes or No will both still lead to a market). There is a many-to-many relationship between service and product as well...which means there is a "3node" relationship - A prospect is defined as a particular partner for a particular product for a particular service, I've tried the following model, but not sure how to query Could_Buy and To_Build together, when there would be multiple of these relationships on a single product.

推荐答案

最适合您的简单设计是创建以下关系:

The most simplistic design that should work for you is creating following relationships:

  1. 节点(合作伙伴)-[提供]->节点(服务)

  1. Node(Partner) - [OFFERS] -> Node(Service)

节点(服务)-[BUILT_WITH]->节点(服务)

Node(Service) - [BUILT_WITH] -> Node(Service)

示例:PartnerA-提供-服务A,产品A-BUILT_WITH-服务A,产品B-BUILT_WITH-ServiceB

Example: PartnerA - OFFERS - ServiceA, ProductA - BUILT_WITH - ServiceA, ProductB - BUILT_WITH - ServiceB

现在如何回答您的业务问题:

Now how to answer your business questions:

  1. Is this Service offered by this Partner?:这很简单.您只需要检查服务和合作伙伴之间是否存在优惠"关系.
  2. What's my market for Product A?:您可以获取所有服务"BUILT_WITH"产品A(即ServiceA).接下来,获取与ServiceA不存在"OFFERS"关系的所有Partner节点. 可以肯定的是,单个查询可以帮助Neo4j实现此结果.
  1. Is this Service offered by this Partner? : This is pretty straight forward. You just need to check if 'OFFERS' relationship exists between a Service and a Partner.
  2. What's my market for Product A?: You can fetch all Services 'BUILT_WITH' Product A. (which is ServiceA). Next, fetch all the Partner nodes for which 'OFFERS' relationship doesn't exist with ServiceA. Pretty sure, a single query can help achieve this result in Neo4j.

这篇关于图形建模布尔值-关系属性,还是节点属性,或者根本没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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