Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neo4j Cookbook

You're reading from   Neo4j Cookbook Harness the power of Neo4j to perform complex data analysis over the course of 75 easy-to-follow recipes

Arrow left icon
Product type Paperback
Published in May 2015
Publisher
ISBN-13 9781783287253
Length 226 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ankur Goel Ankur Goel
Author Profile Icon Ankur Goel
Ankur Goel
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Neo4j 2. Connecting to Neo4j FREE CHAPTER 3. The Cypher Query Language 4. Data Modeling and Leveraging with Neo4j 5. Mining the Social Treasure 6. Developing Location-based Services with Neo4j 7. Visualization of Graphs 8. Industry Usages of Neo4j 9. Neo4j Administration and Maintenance 10. Scaling Neo4j Index

Importing data from RDBMS to Neo4j

Graph data comes in different formats, and sometimes it's a combination of two or more formats. It is very important to learn about the various ways to import data having different formats into Neo4j. In this recipe, you will learn how to import data present in an RDBMS database, such as MySQL, SQL Server, into the Neo4j graph database server. Following is a sample figure for a graph:

Importing data from RDBMS to Neo4j

Getting ready

To get started with this recipe, install Neo4j by using the steps from the earlier recipes of this chapter.

How to do it...

The data from RDBMS can be imported by using the two methods described here.

Using the Neo4j SQL importer tool

Peter Neubauer, the man behind the Neo technology, has developed an excellent tool for this purpose, called the Neo4j SQL importer tool, which takes SQL dumps. The tool can be cloned from his repository over GitHub, which is available at https://github.com/peterneubauer/sql-import.

Using custom scripts

Custom scripts can be written for a particular RDBMS schema, which is more useful as it is designed by keeping the schema in mind. Take an example of the following schema:

Using custom scripts

The Orders and Products tables will represent nodes in Neo4j, while OrderDetails will represent the relationships between them. Relationships can be in both the directions. So, starting from the Products node, we can easily find out how many different Orders have been made for that product and vice versa.

How it works...

In the SQL import tool, most of the things revolve around the primary key. Each of the columns can be made a node, and it will have a relationship with the node that is storing the primary key. In the case of relationships with other tables, the relationship will be made on the foreign key.

There's more…

One of the best use cases of Neo4j is to build a recommendation engine on top of it. Since most of the data now resides in traditional RDBMS, the very first step will involve importing the data into Neo4j.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image