Over a million developers have joined DZone.

Neo4j: Exploring New Data Sets With Help from the Neo4j Browser

· Java Zone

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

One of the things that I’ve found difficult when looking at a new Neo4j database is working out the structure of the data it contains.

I’m used to relational databases where you can easily get a list of the table and the foreign keys that allow you to join them to each other.

2013 10 17 21 27 36

This has traditionally been difficult when using Neo4j but with the release of the Neo4j browser we can now easily get this type of overview by clicking on the Neo4j icon at the top left of the browser.

We’ll see something similar to the image on the left which shows the structure of my football graph and we can now discover parts of the graph by clicking on the various labels, properties or relationships.

For example, if we click on the Month label the following query will be executed:

2013 10 18 11 59 49

That query actually returns all the months in the database since there are only 12 in total, but for other queries we’d get back a subset of the nodes/relationships with that structure.

To explore the structure around the months we might explore which relationships it has by running a query like this:

2013 10 18 12 18 54

From running this query we learn that there is a in_month relationship connecting matches to the month that they were played in.

Another useful exploration mechanism is the allShortestPaths function which will show us the path between two nodes if one exists. For example the following query would show us the path between Wayne Rooney and March:

2013 10 18 12 27 12

The text is a bit small but the relationship between Rooney and a match is named played_in so if we want to find which matches Rooney played in in March we could easily write that query.

Another neat feature of the browser is that we can save our queries as we go by clicking on the save button and optionally naming the query in a comment:

2013 10 18 12 37 31

We can then access those queries and re-run them if we want via the star tab on the left hand side:

2013 10 18 12 34 06

You can get a hold of the browser by downloading milestone 2.0.0-M06 about half way down the download page or if you want to hack on the browser it’s on github.

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

Published at DZone with permission of Mark Needham, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}