DEV Community

Cover image for Can I use Apache AGE to handle both graph and relational data in a single query?
Muhammad Muneeb Ur Rehman
Muhammad Muneeb Ur Rehman

Posted on

Can I use Apache AGE to handle both graph and relational data in a single query?

There is no way to handle both graph and relational data at the same time in a single query in Apache AGE. If you have a graph with nodes representing customers and orders, and you have a relational database containing customer and order details. In that case, you need to convert your relational database containing customer and order details to nodes representing customers and orders.

Solution for this Scenario
You can import and save your relational data in csv file and then you can convert it to nodes and edges as follow:

Nodes
First create a vertex label for the node.
SELECT create_vlabel('agload_test_graph','Country');

Then load data from csv file to the nodes. One node will be created for each tuple (row) and that's node label will be Country.
SELECT load_labels_from_file('agload_test_graph',
'Country',
'age_load/countries.csv');

Edges
First create an edge label for the edges.
SELECT create_elabel('agload_test_graph','has_city');

Then load data from csv file to the edges.This csv file will contain the relationship between nodes.
SELECT load_edges_from_file('agload_test_graph', 'has_city',
'age_load/edges.csv');

Apache AGE provides you facility to do Hybrid Query (Cypher + SQL) to get data (nodes and edges) from the Graph Database. It does not mean you can get data from Relational and Graph databases at the same time in single query.

For more details visit: https://age.apache.org/overview/

AGE Github Link: https://github.com/apache/age

AGE Viewer Github Link: https://github.com/apache/age-viewer

Top comments (0)