Editing Data in Neo4j Graphs doesn’t have to be hard
Let’s be honest: graph databases are remarkable. They can handle billions of nodes and relationships and really, if you’re still using a RDBMS — with those 70's style tables and foreign-keys — you need to reconsider!
I stopped using any other type of database about 5 years ago and only use graphs for all of the software projects I design, develop and manage.
One of these graph solutions, my personal favorite (and I believe the market leader with customers like ebay and NASA), is neo4j. My experience with it: it’s fast; it’s reliable; it has its strong points; it has weaknesses. Overall though, I would recommend it to anyone, anytime.
Neo4j comes with a nifty tool called Neo4j Browser that lets you enter queries in the (proprietary) query language “Cypher” (which I really enjoy, BTW) and even shows results as nice visual graphs. However, it is a real pain the in proverbial butt to perform simple tasks like manipulating the actual data of nodes and relationships — a task we need to perform frequently in the projects we manage!
Sure, graphs are great for analyzing, well, anything! Finding paths, defining communities, ranking relationships, and so on. And these kinds of use-cases are really all you ever hear about. Yes, graph DBs like neo4j can help with things like decoding the Panama Papers, figuring out how COVID-19 spreads across the globe or finding and visualizing trolls in social networks.
But let’s just think about that last example for a second: if you build your social network on top of a graph database, and of course you should, then you will surely need to actually store some data — properties like “username” or “email” on nodes, or maybe a “timestamp” on the “LIKES” relationship between a person and another user’s picture of a cat. After all, the social network needs data to be of any interest, right?
Let’s take a (very simple) look at a (very simple) task then. Let’s assume that we need to edit a single value on a single relationship like the star-rating of a review. We fire up the “neo4j Browser” and look for the desired node:
WHERE p.username=’jessica’ AND id(m)=111
The result is a simple (sub-)graph with the 2 selected nodes. We can click on the REVIEWED relationship to see its properties. Yes, it works. But as soon as there are more than just a few properties on a node/rel, or a large value like the full text of the review, this becomes very clumsy.
Neo4j Browser is made to return query results and visualize graphs. It does that really well and even has some nice features to specify sizes, colors and preferred labels for the different types of nodes. BUT, it’s not made to show or even edit the actual data — the properties of nodes and relationships. So in order to change a value, this is what we have to type:
WHERE p.username=’jessica’ AND id(m)=111
All of that just to set a single property?!
We have to type a lot (and know exactly how) and we can easily make mistakes here: What if p wrote 3 different reviews of m? Then that query overwrites the star-rating of all of them!
This is just a simple example, but believe me, I have messed up my fair share of data in (production-)graphs typing out huge Cypher queries just by making a tiny little mistake somewhere along the line! :facepalm:
This is exactly the reason why I have stopped performing these kinds of manual queries and instead developed a nice GUI for neo4j nodes and relationships. The first version (back in 2016) was a WAR file you had to deploy in an app server like Tomcat. It was OK and helped me and my colleagues a lot. There was room for improvements, though, which is why I started from scratch, rewrote the entire thing (based on React this time), and put in every feature from every wish-list while I was at it!
The result: Neo4j Commander
It has become absolutely vital in our daily lives, filled with 2nd-level-support tasks, and I believe it can be an amazing tool for many other neo4j users/admins. It even comes with an UNDO history because, at the end of the day, we are all just human ;-)
So let’s check out how we would perform that same operation illustrated above using Neo4j Commander:
- Find User with username ‘jessica’
- Open the relationship connecting the desired Movie
- Add the “stars” property of type Integer and set the value to 3
Made a mistake? Hit the UNDO button.
Need to edit the long review text? Use the full-screen editor.
Need to calculate a value based on other values? Use the built-in calculator.
Neo4j Commander is all about the actual data in the nodes and relationships in your Neo4j graph.
Find out everything there is to know and drop us a note if you have any questions, feature-requests or bug reports on the neo4j Commander website: https://netbizltd.com/neo4j
You can install Neo4j Commander in Neo4j Desktop from the built-in Graph App Gallery
Or paste the following URL into the Install form on the Graph Apps pane:
If you love what you see and want to unlock the full potential of Neo4j Commander, I — and of course the company that pays for my time developing this beast — appreciate your upgrade to the PRO version!