Hadi Fadlallah
Installation complete form

Migrating SQL Server graph databases to ArangoDB

June 10, 2021 by

This article will explain ArangoDB, how to install it on Windows, and how to migrate a SQL Server graph database to this NoSQL database management system.

This article is the fifth article of the NoSQL databases series that aims to explain different NoSQL technologies and how to integrate them with SQL Server.

Introduction

As mentioned in this series’s previously published article, the SQL Server graph database is not a native graph; Microsoft added the graph database capabilities on the top of the relation database model. While the hybrid approach provided in SQL Server may help some use cases, especially when we need to integrate graphs with relational tables, native graph databases are still more powerful and reach a higher maturity level.

In the previous articles, we explained how to migrate SQL Server graph databases to the Neo4j graph database. This article is intended for the ArangoDB developers to help them in performing this migration process.

What is ArangoDB?

ArangoDB is an open-source multi-model NoSQL database. It supports three data models:

  1. Document database
  2. Key-Value database
  3. Graph database

The multi-model paradigm allows users to combine each data model advantage within one context. For example, it allows creating nested documents within a graph database or benefiting from the key-value pairs’ high performance in a graph-connected environment.

This database management system was first released in 2011 as AvocadoDB, then renamed to ArangoDB in 2012. As shown in the GitHub repository, ArangoDB is written in C++ (46.4%) and Javascript (48.8%).

Programming languages used in the ArangoDB GitHub repository

Figure 1 – Programming languages used in the ArangoDB GitHub repository

In ArangoDB, data is stored as JSON and can be queried using the ArangoDB query language (AQL).

How to install ArangoDB on Windows?

To install ArangoDB, first, we should open a web browser and navigate to the ArangoDB website. Then, we should click on the “Download” button located in the top right corner.

ArangoDB home page

Figure 2 – ArangoDB website

If we are looking to download the free edition, we should click on the “Get Community edition” link located below the “Download Enterprise Edition” button on the download page.

Download community edition

Figure 3 – Download community edition

Now, we should click on the Windows icon.

Select Windows operating system

Figure 4 – Select Windows operating system

Now, click on the ArangoDB Server NSIS package to download the installation file.

Downloading ArangoDB Server installation file

Figure 5 – Downloading ArangoDB Server installation file

Once the file download is complete, we should open it to start the installation. In the installation wizard, you have first to agree with the end-user license agreement. If you want to change the ArangoDB installation path, you can check the “Choose custom install paths for databases and installation” option.

Installation configuration form

Figure 6 – Installation configuration form

Then, you can enter the ArangoDB root user password (optional).

Changing root user password

Figure 7 – Changing root user password

You can keep the “Launch ArangoDB?” option checked to launch the web interface after closing the wizard at the end of the installation.

Installation complete form

Figure 8 – Installation complete form

In the web interface, you are asked to login into ArangoDB. For the first time, you should use the “root” user with the password you entered in the installation (use blank if no password was specified).

Login form

Figure 9 – Login form

Next, you have to select the database. For the first time, only _system database is available.

Selecting the current database

Figure 10 – Selecting the current database

To add a new database, in the left side menu, click on “Databases”, then click on the “Add Database” button as shown in the image below.

Adding a new database to import nodes and edges from the SQL Server graph database

Figure 11 – Adding a new database

Next, we should set the new database name (In this tutorial, we will set it to “TestGraph”).

Setting the database name

Figure 12 – Setting the database name

To change the current database, click on the database name on the top-right corner of the page. This will get you back to the database selection form.

Changing the current database

Figure 13 – Changing the current database

Exporting SQL Server graph databases to ArangoDB

After illustrating the ArangoDB community edition installation, we will explain how to migrate SQL Server graph databases to ArangoDB using C#.

Getting things ready

First, let us start by creating a C# .Net Core console application in Visual Studio (steps explained in this article: Migrating SQL Server graph databases to Neo4j)

Next, we should open the Nuget package manager in Visual Studio, search for ArangoDB, select ArangoDB.Client NuGet package. After selecting ArangoDB.Client package, you should check the SQLToArangoDB project, then press on the Install button as shown in the image below.

Installing the ArangoDB.Client NuGet package

Figure 14 – Installing the ArangoDB.Client NuGet package

The same steps should be repeated with the System.Data.SqlClient Nuget package (since we are using .Net Core and this package is not included – like it was in the .Net framework).

  • Note that there are different ArangoDB. Net client NuGet packages, but we used the ArangoDB.Client since it is the most popular package. Moreover, there is no official .NET client provided by ArangoDB; the ArangoDB community provides all drivers. You can check all available drivers on the following page: ArangoDB database client drivers (Java, JavaScript, Go, Python, PHP)

Reading from SQL Server graph database

As explained in the previously published article Migrating SQL Server graph databases to Neo4j, to read and write columns, nodes, and edges information, we will create three classes as follows:

Column.cs

Node.cs

Edge.cs

To read data from the SQL Server database, we created a class called SQLReader.cs. The only parameter the user needs to pass in this class constructor is the connection string (SQL Server instance + database + authentication).

This class contains two functions GetNodes() and GetEdges(), that are used to read nodes and edges from the SQL Server graph database.

SQLReader.cs

Writing Nodes and Edges to ArangoDB

To write exported nodes and edges from SQL Server into the ArangoDB database, we created ArangoDBWriter.cs class. This class takes the following parameters:

  • ArangoDB service URI (default is http://localhost:8529)
  • Database name
  • User name
  • Password

We also defined two functions ImportNodes() and ImportEdges() to import nodes and edges into the ArangoDB database.

ArangoDBWriter.cs

Importing data into ArangoDB

After creating the classes we mentioned above, we will use the following code in the “Program.cs” class to import data from an SQL Server graph database (named GraphPL) into the ArangoDB database (named TestGraph).

Program.cs

To ensure that all nodes and edges are exported successfully to the ArangoDB database, let us open the ArangoDB web interface and then click on the Collections tab. We should see all nodes and edges listed in the Collection tab, as shown in the image below.

Nodes and Edges exported successfully from SQL Server graph database to ArangoDB

Figure 15 – Nodes and Edges exported to ArangoDB

If we click on a collection, we can see all the nodes or edges imported within it (the image below shows the nodes imported into the Cities collection).

Nodes imported into Cities collections.

Figure 16 – Nodes imported into the Cities collection

Conclusion

This article explained briefly the ArangoDB database and how to install it on the Windows operating system. Then, it provided a step-by-step guide to migrate nodes and edges from a SQL Server graph database to an ArangoDB database using C# .Net core application. The code we provided in this article was published on GitHub and may need some improvements.

Table of contents

Import data from MongoDB to SQL Server using SSIS
Getting started with the Neo4j graph database
Migrating SQL Server graph databases to Neo4j
Export indexes and constraints from SQL Server graph databases to Neo4j
Migrating SQL Server graph databases to ArangoDB

Hadi Fadlallah
Graph database

About Hadi Fadlallah

Hadi is an SQL Server professional with more than 10 years of experience. His main expertise is in data integration. He's one of the top ETL and SQL Server Integration Services contributors at Stackoverflow.com . Also, he published several article series about Biml, SSIS features, Search engines, Hadoop, and many other technologies. Besides working with SQL Server, he worked with different data technologies such as NoSQL databases, Hadoop, Apache Spark. He is a Neo4j and ArangoDB certified professional. On the academic level, Hadi holds two master's degrees in computer science and business computing. Currently, he is a Ph.D. candidate in data science focusing on Big Data quality assessment techniques. Hadi really enjoys learning new things everyday and sharing his knowledge. You can reach him on his personal website. View all posts by Hadi Fadlallah

93 Views