本文介绍了在Neo4j中,当粒度级别可以无限时应使用什么级别的特异性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用图形数据库时,最困难的事情就是选择粒度级别.可以说,我有一个图表来说明一周中某些天发生的事情:垃圾日,炸玉米饼星期二,BYOB星期五等.

The hardest thing to wrap my head around when using a graph database, is choosing level of granularity. Lets say I have a graph for things that occur at certain days of the week: trash day, taco tuesday, BYOB friday, etc.

  • 这样,我可以将每天作为节点(星期一,星期二,星期三……),这样可以快速查询特定日期.
  • 我可以创建一个名为Day的节点,并在星期几添加属性名称.这样一来,就可以轻松查询图表中的所有日期.

对我自己来说,使节点非常具体是不好的,因为对粒度没有限制.例如,星期六早上,晚上和晚上,或更糟糕的是,每天每小时每小时都有一个新节点.我还可以说边缘节点是粒度的组成部分,方法是说星期六节点通过晚上"边缘与垃圾日节点相连.

Thinking to myself, making nodes very specific is bad because there is not limit to granularity. For example saturday morning, evening and night, or worse, a new node per hour of each day. I could also make edges a component of the granularity by saying saturday node is linked by "evening" edge to trash day node.

例如,我时不时遇到类似的问题;我应该基于一个人的全名创建一个新节点,还是创建一个具有名称"属性的名为"Person"的节点.然后,我基于方便性将节点指定为特定节点或常规节点,但是我觉得可能缺少一些最佳实践或更高层次的原则.我不清楚如何判断哪种方法更好.

I come across similar problems every now and then, for example; should I create a new node based on a person's full name, or a node called "Person" with property "name". Then I make nodes either specific or general based on convenience, but I feel there may be some best practice or higher level principle I'm missing. It's not clear to me how to judge which way is better.

推荐答案

数据模型的粒度级别应由查询要求决定,而不是相反.也就是说:在对数据库进行建模时,您应该问自己:我将对数据执行哪种查询?".根据该问题的答案,您将获得一个良好的起点,以适当的粒度级别制作一个好的模型.

The level of granularity of your data model should be driven by your query requirements, not the other way around. That is: when modeling your database, you should ask yourself: "what kind of query I will do over my data?". Based on the answers of this question, you will get a good start point to make a good model with an appropriate granularity level.

在Rik Van Bruggen撰写的《 学习Neo4j 》一书中(您可以在此链接),作者谈到了设计图数据库的可查询性:

In the book Learning Neo4j, by Rik Van Bruggen (you can download in this link) the author says about design graph databases for query-ability:

因此,基于此,您的问题的答案 当粒度级别可以不受限制时应使用什么特异性级别?" :这取决于您的查询要求.首先考虑要执行的查询,然后考虑数据模型.

So, based on this, the answer of your question "what level of specificity should be used when granularity level can be unlimited?" is: it depends on your query requirements. Think first in the queries you will do, and after in the data model.

我的建议是:一开始就使模型尽可能简单,并在需要时进行逐步更改.

My suggestion is: keep your model as simple as possible in the beginning and, when required, make gradual changes.

这篇关于在Neo4j中,当粒度级别可以无限时应使用什么级别的特异性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:44