Here are a few guidelines to be able to easily go from your relational model to a graph model:
SQL world | Neo4j world |
Table | Node label |
Row | Node |
Column | Node property |
Foreign key | Relationship |
Join table | Relationship |
NULL | Do not store null values inside properties; just omit the property |
Applying those guidelines to the SQL model in the question and answer table diagram, we built up the graph model displayed in the whiteboard model for our simple Q&A website, earlier in the chapter. The full graph model can be seen as follows:
You can use the online tool Arrows, which enables you to draw a graph diagram and export it to Cypher, the Neo4j query language:
http://www.apcjones.com/arrows.
http://www.apcjones.com/arrows.