Neo4j: a Big Data Solution

Maykon L Fonseca
Quick Mobile Labs
Published in
3 min readAug 24, 2016

Clique aqui para a versão em Português.

One of the biggest challenges of Big Data is to relate large volumes of data in a consistently and efficiently way. When you don’t know what kind of data will be added over time, it becomes more complex yet. Have you ever thought about how good could be relating this data in a graph database? That’s exactly what Neo4j makes possible.

Neo4j is a native graph database highly scalable. It’s purpose-built to leverage not only data but also its relationships. Its native graph storage and processing engine deliver a constant real-time performance.

Before getting deep into Neo4j, you need to know some concepts:

  • Nodes: graph data records;
  • Relationships: connect nodes;
  • Properties: named data values.

The easiest way to start Neo4j is running a container:

docker run --publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data neo4j:3.0

Once the container is running, you can access http://localhost:7474 and login using neo4j/neo4j. Then set a new password.

Neo4j’s initial screen

On this first screen, there are available some introduction texts and tutorials about Neo4j.

On the left side, there are menus and at the top, there is a field where commands can be typed.

Here we execute all operations in Cypher. It is a graph query language from Neo4j.

In order to create a new node, you need to execute:

CREATE (:Movie { title:"The Matrix",released:1997 })

It creates a node with the label “Movie”, which has the properties “title” and “released”. Parentheses are used to represent a node.

Let’s create something a little more complex now:

CREATE (matrix:Movie { title:"The Matrix",released:1997 })
CREATE (cloudAtlas:Movie { title:"Cloud Atlas",released:2012 })
CREATE (forrestGump:Movie { title:"Forrest Gump",released:1994 })
CREATE (keanu:Person { name:"Keanu Reeves", born:1964 })
CREATE (robert:Person { name:"Robert Zemeckis", born:1951 })
CREATE (tom:Person { name:"Tom Hanks", born:1956 })
CREATE (tom)-[:ACTED_IN { roles: ["Forrest"]}]->(forrestGump)
CREATE (tom)-[:ACTED_IN { roles: ['Zachry']}]->(cloudAtlas)
CREATE (robert)-[:DIRECTED]->(forrestGump)

In this example we created Persons related to Movies with different kinds of relationships.

The relationships are shown in brackets and may also have labels and properties like nodes.

The result must be like this:

Then let’s filter some results:

MATCH (p:Person)-[:ACTED_IN]->(m)
WHERE NOT (p)-[:DIRECTED]->()
RETURN p,m

Now we have all “Person”s who “ACTED_IN” in a “Movie” without a “DIRECTED” relationship.

These were just a few simple examples to demonstrate how you can work with relationships and nodes on Neo4j.

Working with Neo4j is very simple, intuitive and flexible. We can do a lot more than shown here.

Take a look at: https://neo4j.com and learn more about Neo4j.

--

--