Compare two graphs and be in full control of their differences in both structure and data.

Compare, Analyze, Fine-tune & Sync

Renko Karman
6 min readMar 11, 2024

Compare41 points-out the differences in both structure and data between two graphs. Easily analyze these differences and set a fine-graded scope for synchronization. The Deep-Sync-option allows you to select whole sub-graphs to replicate.

1. How Compare41 came about

Moving from relational to Graph technology improved the efficiency and performance of the applications we developed and made it easier to adapt to our clients ever evolving requirements. However, when addressing data issues, releasing new code, or preparing data imports; the absence of a comparison tool, akin to what we had in the RDBMS world, posed a significant challenge.

We urgently needed a tool to ensure that major code releases or data imports wouldn’t disrupt data integrity in production or lead to data loss. A tool to precisely assess data quality and analyze the impact of structural and code changes before releasing them to production and facilitate selective data replication from one database to another.

In response to these needs we developed Compare41, a tool that provides detailed control over data and structure differences between two graphs, allowing for precise definition of what to copy between databases in each direction.

In this article, we want to highlight who should use Compare41, how it compares two Graph databases, and how you can leverage the power of the graph, via the intelligent Deep-Sync-option, to enable easy selection of entire sub-graphs of related data for replication.

2. Compare41 could benefit you if:

  • You work in a project that uses a Neo4j or Memgraph Graph database.
  • You are a Neo4j or Memgraph Graph database administrator.
  • You want to write applications using a Neo4j or Memgraph Graph database.

3. Things you can use Compare41 for:

  • Compare two sub-graphs.
  • Select entire database or sub-graphs for synchronization.
  • Prepare data replications in detail.
  • Restore with minimal data loss.
  • Run thorough pre-release tests of code-change impacts.
  • Combine or split graph databases.

4. Comparing two sub-graphs with Compare41

4.1 Scenario

We have two movie databases that do not contain the same set of movie nodes. In one of them, the movie Joker and its related data, such as the ACTED_IN relationships, and some of the Person nodes are missing. In this example we will copy the Joker movie with its related data. See below for a sub-graph of the movie Joker along with its actors.

4.2 Compare two sub-graphs

Even though we have a good idea of the differences between the movie databases, we first want to know the exact details. For that we use Compare41 to run a detailed comparison between the two graphs.

Step 1. Configure connection settings

First, to set up the connection between the databases, we need to fill up the connection settings. If the connection is successful, a confirmation text “Connection established” is displayed.

Step 2. Assign node keys

Because we need a key to match the nodes to compare, and there are no key constraints defined in the movie database, we need to manually assign the key identifier fields.

For the Movie node type, we can set the title and released fields as the key fields, while for the Person node type we can use the name and born fields.

Step 3. Analyze comparison result

Now with these preliminary steps in place, we can compare the databases and analyze their differences.

The comparison result shows the number of nodes unique to each database. The Left Only count shows the number of nodes exclusive to the movie-backup, while the Right Only count shows the number of nodes exclusive to the movie-production. It also shows the number of nodes and relationships that are identical in both databases.

The bottom part of the screen shows the individual items of the selected node type. Here we can see that the movie Joker and Parasite only exist in the movie-backup database, while the movie The Polar Express and When Harry Met Sally only exist in the movie-production database.

By selecting Relationships from the dropdown menu, we can see in the comparison result the individual items having the (Person)-[ACTED_IN]->(Movie) relationship type. Since we are copying the movie Joker, we also care about the relationships that are part of that movie. Looking at the result, we can see that it lacks the actors: Joaquin Phoenix, Robert De Niro and Zazie Beetz.

Step 4. Set scope

To copy the movie Joker to the movie-production database, we need to add it to the sync queue.

4.3 Execute a Deep sync

In other similar software, you would need to manually search for the relevant node types and relationship types, then copy them one by one. This is both cumbersome, time consuming and error prone. Luckily, we are using Compare41, so we don’t need to do that.

Step 1. Select relevant data to include

In Sync Preview, you can refine the sub-graph to synchronize. In our case, we want to copy the movie Joker and its actors, so we need to include its ACTED_IN relationship, together with the relevant Person nodes.

Step 2. Sync or Generate Script

You can decide to either sync now directly to the target database or generate a script to use at a later time.

Step 3. Reevaluate and assess sync results

The comparison results shows that only the movie Parasite remains in the Left Only items. Therefore, the movie Joker and its related data have been replicated successfully.

The comparison result also shows 5 Left Only items for the (Person)-[ACTED_IN]->(Movie) relationship type. If we look at the individual items below, we see that those 5 items are not for the movie Joker, therefore its related relationships have also been replicated successfully!

And we are done! That’s how easy it is to compare and replicate data with Compare41.

If you want to try Compare41 yourself, visit our website https://circlesarrows.com/. Start a free trial to access the full product features, and when your trial expires, you can use the free version.

--

--