Neo4j Graph Database: The non-relational database that improves on relations.
Trienpont International
We are a diverse and talented team that turns your digital dreams into a technical reality.
By Brecht Jan Pallemans
As a Tech Lead at Trienpont International, I often conduct? technical interviews with candidates for our developer role vacancies. A common technology found on? a candidate’s resume is MongoDB - a NoSQL document-oriented database. This almost always leads me to ask: “What is MongoDB, and can you provide an example of when to use it?”.?
In this blog post, I’d like to answer my own question about another NoSQL technology that can be found on my resume: Neo4j.
What is Neo4j?
It is a graph database - not to be confused with the GraphQL query language - in which your data is stored as ‘nodes’ and ‘edges’. The nodes represent entities, and because there are no column definitions, each node can have its own properties. The edges represent relationships. Unlike in a “relational” database where a relationship is just a reference to a record in another table, properties can be assigned to an edge. The data structure of nodes and edges together is called a ‘graph’.?
Let’s clarify that with an example:
In this graph, we have two nodes representing players in a TV show. The players have to find the lying player and have a certain amount of suspicion towards all other players. The connection between John and Jane is that John suspects Jane of being the liar.?
Neo4j uses the Cypher query language. Using Cypher, we can model John and Jane like this:
(:Player { name: ”John” })-[:SUSPECTS { level: ”0.7” }]-(:Player { name: ”Jane” })
As you can notice in the statement, we can add a property to the relationship. John is 70% certain about his suspicion. This allows for a unique querying ability on the relationships themselves!?
Neo4j is a native graph database, it implements a graph model on the storage level. Its enterprise edition supports backups, clustering and has failover abilities. And on top of that, it's fully open source, so you can check out the Java/Scala code on GitHub yourself.?
领英推荐
When to use Neo4j?
As humans, we tend to stick to technologies that we know work well. We use SQL databases as a standard solution when there are other, often better, alternatives out there. In scenarios where the relationships between data points are as important as the data points themselves, Neo4j can be a game changing technology to add to your stack.?
Using Neo4j makes it easy to navigate deep hierarchies and find hidden connections between entities. Some examples where this could come in handy include:
In all of the above examples, it would become very complicated quickly using SQL tables to relate entities with each other. Neo4j allows the application to scale and expand after new discoveries are made without altering the existing entities.?
I recommend starting with a small microservice implementation, and gradually adding more services reliant on a Graph Database to your application while the application scales. It is a technology that? can speed up the development and performance of some interconnected parts of your application where querying is traditionally complex.?
Conclusion
The Neo4j Graph Database offers a powerful way to manage complex data relationships. Its node-and-edge structure excels in areas like recommendation engines and fraud detection.?
At Trienpont International, our team of tech specialists can help you build robust software projects using Neo4j. If you are interested in creating innovative solutions with Neo4j, contact us to discuss how graph databases can improve your business.?
Let’s chat and explore the possibilities together