First, I recommend that you think about what you want to do with your data . You do not use a graphical database for simple data storage, you also want to do something with it. Thus, you probably have a specific use case, such as finding a path. In this case, there are not many options, but there is another way to model the data. In this case, I would consider the algorithms already provided and whether they could process what I want to do with it. So let's say that I want to use apoc.algo.aStar, because it is capable of doing what I want to do. At this stage, I restrict myself to the fact that aStar is able to process weights only by relations, and the algorithm wants to have coordinates on the nodes. This is probably also the first scheme you were thinking about, but I think you understood it. If there is no algorithm for your problem, you will make the algorithm yourself. Take a look at the options you have, and you'll often be limited to a specific way to model your data.
As already mentioned, the way you process your data also affects how quickly you can request certain things. For example, you are modeling a map, so you have point A and point B at which you want to go from A to B and B to A. The problem in neo4j is that you do not have a bi-directional edge. So you might consider adding 2 edges, from A to B and from B to A. Don't do this! Performance will be hit hard.
- I can make node (Mon, Tue, Wed, ...) every day, so requests for specific days are fast.
- I can make a node called "Day" and add the property name to the day of the week. Thus, showing all the days on the chart, it is easy to request for.
Ask yourself why you have this database and what you want to do with it, and don't forget about indexing. You can still create an index to get some performance back that you still had in the first example. Also avoid adding redundant data. For example, node is a day connected to all business days. Everyone knows that Friday is a day. Just think about it if you benefit from it. After modeling several graphs, as well as writing your own algorithms for graphs, you will feel it. At some point, you will know how best to create graphics for specific cases. Experience is the key to charting, knowing the limitations of the algorithms that you can already use, and what you can do yourself. Hope this helps.
source share