简体   繁体   English

如何设计与其他节点有序关系的neo4j db节点

[英]How to design neo4j db nodes that have ordered relationship with other nodes

I'm trying to design a Neo4j graph database, and I will illustrate my specific requirement. 我正在尝试设计Neo4j图形数据库,我将说明我的具体要求。 I'm designing an app that allows users to collaborate on the books and magazines they have read. 我正在设计一个应用程序,允许用户在他们阅读的书籍和杂志上进行协作。 Requirements: 要求:

  1. The same Book can be read by multiple people 同一本书可以被多人阅读
  2. The order in which a specific person reads the books is important. 特定人阅读书籍的顺序很重要。 For example, I want to be able to represent that Person A read Books B1 and B2 in that order, while Person B may have read Books B3, B2 and B1 in that order. 例如,我希望能够代表人A以此顺序阅读书籍B1和B2,而人B可能以该顺序阅读书籍B3,B2和B1。

    I'm thinking of having nodes representing a Book, Magazine, Person, etc. 我正在考虑具有代表书籍,杂志,人物等的节点。

What is the best way to ensure the order/sequence information? 确保订单/序列信息的最佳方法是什么? A couple of options I thought about: 我考虑过几个选择:

  1. Store a order ID or timestamp in the relationship between a Person and a Book node and use that to query all Books read by the person in the right order. 将订单ID或时间戳记存储在Person和Book节点之间的关系中,并使用该ID或时间戳查询该人按正确顺序阅读的所有Book。
  2. Store a Next/Previous relationship between Book nodes, but this approach will not work because the order can vary depending on which person read the books. 在“书”节点之间存储“下一个/上一个”关系,但是这种方法不起作用,因为顺序可能会因阅读该书的人而异。

To me this is the way to go, easy and effective. 对我来说,这是简单有效的方法。

Store a order ID or timestamp in the relationship between a Person and a Book node and use that to query all Books read by the person in the right order. 将订单ID或时间戳记存储在Person和Book节点之间的关系中,并使用该ID或时间戳查询该人按正确顺序阅读的所有Book。

Storing a Next/Previous relationship will not work, because you would have to save UserID in the NEXT relationship between books and that is just nonsense. 存储下一个/上一个关系将不起作用,因为您必须将UserID保存在书籍之间的NEXT关系中,这只是废话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在java中的neo4j嵌入式数据库中,我应该如何检查两个节点是否相互关联? - How should I check if two nodes have relationship with each other,in neo4j embedded database in java? 如何在Neo4j中按关系匹配2个节点? - how to match 2 nodes by relationship in Neo4j? 如何查询Neo4j节点及其之间的关系? - How to query Neo4j nodes and the relationship between the nodes? 如何返回neo4j中具有一定关系的节点,然后返回与第一个节点具有不同关系的节点? - How do I return nodes in neo4j that have a certain relationship, and then return nodes that have a different relationship with the first nodes? Neo4j中涉及3个NODES和1个RELATIONSHIP的域设计 - Domain design involving 3 NODES and 1 RELATIONSHIP in Neo4j Cypher / Neo4j:如何匹配与所有相关节点有关系的节点 - Cypher/Neo4j: How to match nodes that have relationship to all related nodes neo4j cypher - 如何查找与节点列表有关系的所有节点 - neo4j cypher - how to find all nodes that have a relationship to list of nodes neo4j中的三个节点之间的“之间”关系或图db - A “between” relationship between three nodes in neo4j or a graph db 如何检查节点列表是否遵循neo4j中的有序路径? - How to check a list of nodes follows an ordered path in neo4j? 查找没有特定关系的节点(Cypher / neo4j) - Finding nodes that do not have specific relationship (Cypher/neo4j)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM