[As community content, this post reflects the views and opinions of the particular author and does not necessarily reflect the official stance of Neo4j. This was originally posted on the Knoldus blog and was used with permission.]Editor’s Note: In this blog post, guest author Anurag Srivastava gives you an introduction for using Neo4j together with Scala. For more information on the Scala driver for Neo4j – AnormCypher – check out our developer page here.
When we use a relational database for storing data, we store data in predefined tables and then define foreign keys for references between tables or rows. But when it comes to graph databases, we store data in nodes and relationships. Graph databases provide us with flexibility to arrange data in easy way.
When transforming a data model from a Relational Database Management System (RDBMS) to a graph database, here are some transformations we’ll need to make:
- Tables are represented by labels on nodes
- Rows in an entity table become nodes
- Columns on those tables become node properties
- Remove technical primary keys and keep business primary keys
- Add unique constraints for business primary keys and add indexes for frequent lookup attributes
- Replace foreign keys with relationships to the other table and remove them afterwards
- Remove data with default values – no need to store those
- Data in tables that are denormalized and duplicated might have to be pulled out into separate nodes to get a cleaner model
- Indexed column names might indicate an array property
- JOIN tables are transformed into relationships and columns on those tables become relationship properties
Read the rest of this blog post on Scala for Neo4j by Anurag Srivastava on the Knoldus blog.
Want to learn more about graph databases and Neo4j? Click below to register for our online training class, Introduction to Graph Databases, and master the world of graph technology.