图形数据库建模:我应该使用一个集合节点来避免许多相关节点 [英] Graph database modelling: Should i use a collection node to avoid to many rel on a node

查看:129
本文介绍了图形数据库建模:我应该使用一个集合节点来避免许多相关节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究使用Graph数据库(Neo4J)的第一个应用程序。我正在对白板上的图形进行建模。我和我的同事正在嘲笑我们是否应该引入收集节点。

我们有类似的东西(Cypher语法,虚构例子):
(parking:Parking) - 停车节点
(car:Car) - Car node



显然,一个停车场可以有多辆汽车,假设它可以有多达100万辆汽车。在这种情况下,最好引入一个新节点:$ b​​ $ b(carCollection:CarCollection) - 汽车集合节点?

b

停车场可能有相对于可以拥有大量汽车的汽车集合节点。这应该避免在泊车节点上自行执行一个简单的查询(假设您想查询可用座位的数量),从而失去性能。
这是个好主意吗?如果任何人都可以提供链接或书籍以及一些图形建模的最佳实践,那么这是否是假的,你应该如何模拟它,并且这不会影响性能?那就太棒了)。

thx提前。

Gr
Kwinten

解决方案

无论如何,一旦您需要为每辆汽车安装1mil节点,就无法实现性能增强。 b
$ b

如果您只需要一辆汽车就可以查询您的停车节点,那么速度就如同汽车收藏中只有一辆汽车一样快。



如果您需要返回所有1密耳的汽车,则不需要增强器。 (但主要问题只是流式传输所有数据的网络连接)。



你可以使用 labels ,但我建议将数百万的关系直接留在停车节点上。但是如果你可以给我们提供一个查询的例子,那么我们可能会发现smthnig出来了。


I'm currently working on my first application that uses a Graph database (Neo4J). I'm in the process of modelling my graph on a whiteboard. My colleague and I are in a pickle on whether or not we should introduce a 'collection node'.

We have something like this (Cypher syntax, Fictive example): (parking:Parking) - Parking node (car:Car) - Car node

Obviously, a Parking can have multiple Cars, let's say it can have up to 1mio cars.

Is it, in this case, better to introduce a new node: (carCollection:CarCollection) - Car collection node?

A Parking could have a rel to the 'Car collection node' which can have a lot of cars. This should avoid a simple query being performed on the Parking node it self (let's say you want to query the number of available seats) to lose performance. Is this a good idea? Or is this bogus and should you model it as it is, and does this not influence performance?

If anyone can provide a link or book with some graph modelling best practices, that would be awesome as well :).

Thx in advance.

Gr Kwinten

解决方案

anyhow, there is no way of a performance enhancer once you need to have 1mil nodes for each car.

if you will simply query your parking node with just one car, it will be as fast as if you have just 1 car in the car collection.

if you will need to return all 1 mil cars, than there is no enhancer. (the main problem, however, would be simply the net connection to stream all the data).

you can play with labels, but i suggest to keep the millions of relations directly to the parking node. but if you could provide us with an example scenario with a query, than we can figure maybe smthnig out

这篇关于图形数据库建模:我应该使用一个集合节点来避免许多相关节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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