GraphDB:节点作为关系的属性 [英] GraphDB: Node as a property of a relationship

查看:66
本文介绍了GraphDB:节点作为关系的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试分析graphDB作为问题域RDBMS的替代方案.这是我要解决的问题的类比.

I am trying to analyze graphDB as an alternative to RDBMS for a problem domain. Here is the analogy of a problem I am trying to solve.

P:Michael P:Angela r:like_to_eat G:Apple G:面包. G:Apple G:Bread r:available_in S:Walmart S:Whole Foods.到目前为止,这很简单.这是我认为最能表达图表的图像.

P:Michael and P:Angela r:like_to_eat G:Apple and G:Bread. G:Apple and G:Bread are r:available_in S:Walmart and S:Whole Foods. So far it's straightforward. Here is an image that I think best expresses the graph.

问题是当我尝试指定安吉拉喜欢全食食品中的苹果和沃尔玛的面包时.迈克尔喜欢吃沃尔玛的苹果和全食的面包.如何在图形中表示类似的内容?听起来我需要一个超图的概念才能解决这个问题,但是我也听说任何超图问题也可以使用属性图来解决.可以使用Neo4j或CosmosDB等标准图形解决方案解决此问题吗?有人可以帮我吗

The problem is when I try to specify that Angela likes Apples from Whole Foods and Bread from Walmart. And Michael likes to eat Apples from Walmart and Bread from Whole Foods. How can I represent something like that in a graph? It sounds like I need the concept of a hypergraph to be able to solve this problem, but I have also heard that any hypergraph problem can be solved with property graph too. Can this be solved using standard graph solutions like Neo4j or CosmosDB? Can someone please help me with this

推荐答案

您可以验证"三向关系(在 Person Grocery Store )在一个 Preference 节点(例如)中,从而得到如下数据模型:

You can "reify" the 3-way relationship (between Person, Grocery, and Store) in a Preference node (say), resulting in a data model like this:

在neo4j中,您可以使用以下Cypher查询来表示"Angela喜欢全食食品中的苹果和沃尔玛的面包":

In neo4j, you can use this Cypher query to represent "Angela likes Apples from Whole Foods and Bread from Walmart":

MERGE (angela:Person {name: 'Angela'})
MERGE (apple:Grocery {name: 'Apple'})
MERGE (bread:Grocery {name: 'Bread'})
MERGE (wf:Store {name: 'Whole Foods'})
MERGE (wm:Store {name: 'Walmart'})
CREATE
  (angela)-[:LIKES]->(pref1:Preference),
  (pref1)-[:ITEM]->(apple),
  (pref1)-[:AT_STORE]->(wf),
  (angela)-[:LIKES]->(pref2:Preference),
  (pref2)-[:ITEM]->(bread),
  (pref2)-[:AT_STORE]->(wm)

这篇关于GraphDB:节点作为关系的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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