Neo4j Part 1

[ Neo4j  ] [ GraphDB  ]

Neo4j is a graph database and what means is that rather than having data in a table format the data is displayed as nodes. A traditional database (Relational Database Management System) RDBMS is where the data has “relationships” between each other and is usually stored in tables with columns and rows. A primary key is used to reference a row of data in another table where the primary key becomes a foreign key in the reference table.

Many people are now changing their RDBMS to a Graph Database as seeing the data in a visual format shows the data in a different light and links and relationships are a lot clearer compared an RDBMS to looking at the data in a table.

Properties

Properties of the Neo4j Graph Database:

  • Cypher is used to query the data
  • Nodes is where data is represented
  • Properties is again where data is represented (they are in a key-value pair)
  • Relationships connects nodes together and can either have one or bi-directions

Labels are essential the tables from an RDBMS and they are used are a reference when querying the data.

Nodes are a row from a table in an RDBMS and usually the primary-key is used as the visual name for the node.

an image alt text

Properties are the rest of the columns from the table in an RDBMS and these can be interchangeable with the node name.

Relationships show how nodes of different labels are related to each other and even nodes of the same labels can be related to each other. There are 2 types of relationships one is where it is in one direction and the other is where the relationship can be in both directions.

Transforming an RDBMS

Transforming a RDBMS to a Graph Database can be tricky and a mistake can cause your Graph Database to not show the relationships between nodes.

First you need to get the schema of your current RDBMS with all the tables, relationships, column names, any primary/foreign keys and data types. Only then you can start to transform to RDBMS to a Graph Database.

If you have a table which contains both primary and foreign keys then this usually a joining table and if the table only contains the primary and foreign key then we will use the data to create a simple relationship.

If the table also contains other columns then we would use those other columns to populate the properties for that relationship.

The remaining tables are then considered as labels and each row of data in those tables are nodes. All the data columns for that row are properties of that node and after that there should be no tables left to transfer.

In the next Neo4j blog, I will show you how to write data to the Graph Database via Cypher commands and importing CSV files.

Written on October 23, 2016