Data2Neo - A Tool for Complex Neo4j Data Integration

Julian Minder, Laurence Brandenberger, Luis Salamanca, Frank SchweitzerarXiv 2024 · DOI

Introduction

While relational databases (RDBs) remain the industry standard for structured data storage, their static, table-based architecture is often ill-suited for representing the highly interlinked information required by modern AI applications, such as Retrieval-Augmented Generation (RAG) and Large Language Models (LLMs). Knowledge Graphs (KGs) offer a more flexible alternative, yet the migration process from RDBs to graph databases like Neo4j presents a significant challenge. Developers typically choose between fast but rigid direct imports, user-friendly but limited ETL tools, or highly flexible but maintenance-heavy programmatic scripts.

Data2Neo is an open-source Python library designed to provide a "middle way." It combines the simplicity of a declarative, schema-based approach with the extensibility of Python, allowing for complex data cleaning and transformation within a unified pipeline.

System Architecture

The Data2Neo framework decomposes the integration process into three primary components to balance modularity and performance:

  1. ResourceIterator: This abstraction layer fetches data from diverse sources—including SQL databases and Pandas DataFrames—and categorizes them by "Resource Type."
  2. Conversion Schema: A YAML-like blueprint where users define the mapping between resources and graph elements (nodes and relationships). It supports complex cardinalities, including one-to-many and many-to-one conversions.
  3. Converter: The core engine that orchestrates the data flow, utilizing multi-core parallelization to process large datasets efficiently.
A schematic overview of the Data2Neo workflow, showing data moving from input sources through preprocessors and schemas into a Knowledge Graph.

A critical innovation in Data2Neo is the implementation of Wrappers. These are Python functions registered via decorators that serve as pre- or post-processors. Wrappers allow developers to inject custom logic—such as string normalization, external API calls, or conditional attribute mapping—directly into the pipeline without leaving the library's ecosystem.

Experimental Evaluation

The authors evaluated Data2Neo using two distinct scenarios to test both functional flexibility and raw performance:

  • Retail Sales System: A qualitative test involving five relational tables (e.g., Product, Order, Supplier) to demonstrate schema syntax and the handling of inter-table relationships.
  • GitHub Repository Benchmarks: A quantitative performance test using large-scale open-source data from ansible/ansible, tensorflow/tensorflow, and openshift/origin. These datasets ranged from 7 million to 35 million rows, providing a rigorous test for the library's parallelization capabilities.

Results and Analysis

The performance of Data2Neo was benchmarked against Neo4j’s native Direct Import (DI) tool. While DI is optimized in C++ and remains approximately 2.5x to 3x faster, Data2Neo demonstrated high efficiency for a Python-based tool, processing over 34 million rows in under two hours.

A table comparing the runtime of Direct Import vs. Data2Neo across three GitHub repositories.

Beyond raw speed, the evaluation highlighted several key advantages of Data2Neo:

  • Reduced Cognitive Load: A 1,000-character Data2Neo schema was found to replace approximately 2,500 characters of complex Cypher/APOC scripts, significantly improving maintainability.
  • Automated Merging: By utilizing "primary attributes," the library automatically handles node merging across disparate data sources, ensuring data integrity in the resulting Knowledge Graph.
  • End-to-End Integration: Unlike DI, which requires data to be pre-formatted into specific CSV structures, Data2Neo manages transformation, cleaning, and graph generation in a single step.

Conclusion

Data2Neo offers a robust solution for engineers who require a balance of flexibility and performance in Knowledge Graph construction. While it carries a performance overhead compared to native database import functions due to its Python foundation, its ability to handle complex logic via Wrappers and its declarative schema approach make it a powerful tool for modern data integration tasks. Future work will focus on optimizing parallelization strategies and expanding the library's native support for additional data sources.

Summary updated

BibTeX
@misc{minder2024data,
  author = {Julian Minder and Laurence Brandenberger and Luis Salamanca and Frank Schweitzer},
  title = {{Data2Neo - A Tool for Complex Neo4j Data Integration}},
  year = {2024},
  eprint = {2406.04995},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.04995},
}
Figure