Graph database modelling: Should i use a collection node to avoid to many rel on a node

折月煮酒 提交于 2020-02-07 12:40:51

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/24860903/graph-database-modelling-should-i-use-a-collection-node-to-avoid-to-many-rel-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!