A Graph Database: Neo4j

As explicitly pointed out, we choose to use the NoSQL graph database, Neo4j.

It is one of the most popular graph database currently and is very performant in read/write queries.

It represents data as Nodes and Relationships. Nodes are linked to other nodes through relationships. Those two objects can have multiple Properties containing different types of information about a given instance of a node/property.

Neo4j has its own query language: Cypher. Is very similar to the well-known SQL query language.

Here is a simple example returning all nodes of type Car of brand Porsche:

MATCH (node:Car{brand:"Porsche"}) RETURN node

We first created a database locally on our computer to start developing our python code managing and accessing our data. We will move this database into a real server when our jukebox application will be operational.

In order to manage our database we use the python API py2neo. It provides many different ways to communicate to our server while translating our python code into server-readable Cypher queries.

In our current graph database, each nodes represent a beat. Each beat is given a temporal index as well as the name of the music from which it belongs to. Two beats are linked by the property “SIMILARTO” if they are similar (linked in original graph) which has a similarity weight.
Here is an example of relation creation for the two beats (1,2) of the music “Creep” of Radiohead:

CREATE n1-[:SIMILARTO{similarity:0.6}]->n2

If you remember well our last article, each similarity weight is equivalent to a jumping probability.


(graph database view for 25 nodes)

Leave a Reply

Your email address will not be published. Required fields are marked *