AgensGraph Tutorial
Import, Query, and Modify Graph Data

Before Getting Started!

The goal of this tutorial is to give users guidance in how to load sample data into AgensGraph, query the loaded data, and/or extract the desired information.

In order to load and use data as guided in this tutorial, AgensGraph should be installed first. You can install/use AgensBrowser, a visualization tool, as well, for easier and quicker analysis of the sample data.

In general, there are two ways to load data into AgensGraph:

  1. Import dataset files into AgensGraph.
  2. Execute queries on AgensGraph to generate the data.

This tutorial describes how to import a dataset file (CSV) into AgensGraph. If you want more information on how to generate data using queries, please visit Bitnine's website and read Basic Cypher and Advanced Cypher white papers. The link to download the dataset we use here is given below.Throughout this tutorial, the results of creating, reading, updating, and deleting (CRUD) data in AgensGraph are shown and described using AgensBrowser, a visualization tool. Please note that some of the product features (AgensBrowser 2.1) introduced here are only available in AgensGraph Enterprise Edition.

See Bitnine's website for more information about the Enterprise Edition.

In AgensGraph, you can refer to Help on the general database features by typing in \? and on SQL and Cypher by \help. If you have any question on the AgensGraph features described in this tutorial, please use Help.

Contents of this tutorial

  1. Dataset Overview
  2. What is, and How to Generate Graph Model
  3. Export Dataset from RDB to CSV
  4. Import CSV to AgensGraph
  5. Querying Graph Data
  6. Updating Graph Data
  7. Notes

01. Dataset Overview: Northwind

This tutorial uses Northwind, a sample dataset widely used in RDBMS. It is true that the Northwind dataset is mostly used for examples of relational data, but it can be used as examples of graph data as well. This dataset contains sales data of a fictitious company called Northwind Traders, an importer/exporter of specialty foods from/to the global market. The Northwind dataset used in this tutorial consists of a total of 11 tables, 6 vertex labels, and 6 edge labels and covers 91 customers, 830 ordering records, and 77 types of products sold.

The entity-relationship diagram of the dataset is shown below :

northwind

02. What is, and How to Generate Graph Model

A graph model means a data model that is implemented in graph where data are linked by points (nodes or vertices) and lines (links or edges), rather than in a table format consisting of rows and columns.

The followings shall be noted when switching from a relational model (that uses tables) to a graph model:

  • "row" in a relational model corresponds to a vertex or an edge with properties in a graph model
  • "table name" in a relational model corresponds to "vertex label" and "edge label" in a graph model.

The graph model of Northwind is as follows:

metadata

One of the biggest differences between graph model and relational model is that only graph model reflects the reality (business) model as it is.

Relational model processes complicated real-world business model and transform them into a table.

The problem is that the business model in the real world is in the form of relationships (edges) among objects (vertices), and analogous objects are combined and represented by a group (label), all of which is quite similar to the way graph model is implemented.

03. Export Dataset from RDB to CSV

If you have a Northwind dataset in your existing legacy RDB and want to load it into AgensGraph, you must first export the dataset in the RDB to CSV before loading.

COPY (SELECT * FROM categories) TO 'D:\northwind\exp\categories.csv' WITH CSV header;             
                              COPY (SELECT * FROM customers) TO 'D:\northwind\exp\customers.csv' WITH CSV header;               
                              COPY (SELECT * FROM employees) TO 'D:\northwind\exp\employees.csv' WITH CSV header;               
                              COPY (SELECT * FROM employee_territories) TO 'D:\northwind\exp\employee_territories.csv' WITH CSV header;    
                              COPY (SELECT * FROM orders_details) TO 'D:\northwind\exp\orders_details.csv' WITH CSV header;           
                              COPY (SELECT * FROM orders) TO 'D:\northwind\exp\orders.csv' WITH CSV header;                  
                              COPY (SELECT * FROM products) TO 'D:\northwind\exp\products.csv' WITH CSV header;                
                              COPY (SELECT * FROM regions) TO 'D:\northwind\exp\regions.csv' WITH CSV header;                 
                              COPY (SELECT * FROM shippers) TO 'D:\northwind\exp\shippers.csv' WITH CSV header;                
                              COPY (SELECT * FROM suppliers) TO 'D:\northwind\exp\suppliers.csv' WITH CSV header;               
                              COPY (SELECT * FROM territories) TO 'D:\northwind\exp\territories.csv' WITH CSV header;          
                              
                              COPY (SELECT * FROM orders
                              LEFT OUTER JOIN orders_details ON orders_details.OrderID = orders.OrderID) TO 'D:\northwind\exp\orders.csv' WITH CSV header;

04. Import CSV to AgensGraph

AgensGraph Foreign-Data Wrapper (FDW) is needed when importing a CSV-formatted dataset into AgensGraph.

  1. First, install 'file_fdw' extension.

    CREATE EXTENSION IF NOT EXISTS file_fdw;
  2. Create a database connection server.

    CREATE SERVER northwind FOREIGN DATA WRAPPER file_fdw;
  3. Create each foreign table to load a dataset in CSV format.

    CREATE FOREIGN TABLE categories (
                                                    CategoryID int,
                                                    CategoryName varchar(15),
                                                    Description text,
                                                    Picture bytea
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\categories.csv', delimiter ',', quote '"', null '');
    
                                                CREATE FOREIGN TABLE customers (
                                                    CustomerID char(5),
                                                    CompanyName varchar(40),
                                                    ContactName varchar(30),
                                                    ContactTitle varchar(30),
                                                    Address varchar(60),
                                                    City varchar(15),
                                                    Region varchar(15),
                                                    PostalCode varchar(10),
                                                    Country varchar(15),
                                                    Phone varchar(24),
                                                    Fax varchar(24)
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\customers.csv', delimiter ',', quote '"', null '');
    
                                                CREATE FOREIGN TABLE employees (
                                                    EmployeeID int,
                                                    LastName varchar(20),
                                                    FirstName varchar(10),
                                                    Title varchar(30),
                                                    TitleOfCourtesy varchar(25),
                                                    BirthDate date,
                                                    HireDate date,
                                                    Address varchar(60),
                                                    City varchar(15),
                                                    Region varchar(15),
                                                    PostalCode varchar(10),
                                                    Country varchar(15),
                                                    HomePhone varchar(24),
                                                    Extension varchar(4),
                                                    Photo bytea,
                                                    Notes text,
                                                    ReportTo int,
                                                    PhotoPath varchar(255)
                                                )  
                                                SERVER northwind 
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\employees.csv', delimiter ',', quote '"', null '');
    
                                                CREATE FOREIGN TABLE employee_territories (
                                                    EmployeeID int,
                                                    TerritoryID varchar(20)
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\employee_territories.csv', delimiter ',', quote '"', null '');     
    
                                                CREATE FOREIGN TABLE orders_details (
                                                    orderID int,
                                                    ProductID int,
                                                    UnitPrice money,
                                                    Quantity smallint,
                                                    Discount real
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\orders_details.csv', delimiter ',', quote '"', null '');     
    
                                                CREATE FOREIGN TABLE orders (
                                                    orderID int,
                                                    CustomerID char(5),
                                                    EmployeeID int,
                                                    orderDate date,
                                                    RequiredDate date,
                                                    ShippedDate date,
                                                    ShipVia int,
                                                    Freight money,
                                                    ShipName varchar(40),
                                                    ShipAddress varchar(60),
                                                    ShipCity varchar(15),
                                                    ShipRegion varchar(15),                         
                                                    ShipPostalCode varchar(10),                         
                                                    ShipCountry varchar(15)                     
                                                )                          
                                                SERVER northwind                         
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\orders.csv', delimiter ',', quote '"', null '');                         
    
                                                CREATE FOREIGN TABLE products (
                                                    ProductID int,         
                                                    ProductName varchar(40),
                                                    SupplierID int,        
                                                    CategoryID int,        
                                                    QuantityPerUnit varchar(20),
                                                    UnitPrice money,       
                                                    UnitsInStock smallint, 
                                                    UnitsOnorder smallint, 
                                                    ReorderLevel smallint, 
                                                    Discontinued bit       
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\products.csv', delimiter ',', quote '"', null '');
    
                                                CREATE FOREIGN TABLE regions (
                                                    RegionID int,
                                                    RegionDescription char(50)
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\regions.csv', delimiter ',', quote '"', null '');     
    
                                                CREATE FOREIGN TABLE shippers (
                                                    ShipperID int,
                                                    CompanyName varchar(40),
                                                    Phone varchar(24)
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\shippers.csv', delimiter ',', quote '"', null '');     
    
                                                CREATE FOREIGN TABLE suppliers (
                                                    SupplierID int,
                                                    CompanyName varchar(40),
                                                    ContactName varchar(30),
                                                    ContactTitle varchar(30),
                                                    Address varchar(60),
                                                    City varchar(15),
                                                    Region varchar(15),
                                                    PostalCode varchar(10),
                                                    Country varchar(15),
                                                    Phone varchar(24),
                                                    Fax varchar(24),
                                                    HomePage text
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\suppliers.csv', delimiter ',', quote '"', null '');
    
                                                CREATE FOREIGN TABLE territories (
                                                    TerritoryID varchar(20),
                                                    TerritoryDescription char(50),
                                                    RegionID int
                                                ) 
                                                SERVER northwind
                                                OPTIONS (FORMAT 'csv', HEADER 'true', FILENAME 'D:\northwind\territories.csv', delimiter ',', quote '"', null '');
                                            
  4. After creating a graph, specify a graph path.

    CREATE GRAPH northwind_graph;
                                              SET graph_path = northwind_graph;
  5. Now create vertices.

    LOAD FROM categories AS source CREATE (n:category=to_jsonb(source));
                                                LOAD FROM customers AS source CREATE (n:customer=to_jsonb(source));
                                                LOAD FROM employees AS source CREATE (n:employee=to_jsonb(source));
                                                CREATE VLABEL IF NOT EXISTS "order";
                                                LOAD FROM orders AS source CREATE (n:"order"=to_jsonb(source));
                                                LOAD FROM products AS source CREATE (n:product=to_jsonb(source));
                                                LOAD FROM regions AS source CREATE (n:region=to_jsonb(source));
                                                LOAD FROM shippers AS source CREATE (n:shipper=to_jsonb(source));
                                                LOAD FROM suppliers AS source CREATE (n:supplier=to_jsonb(source));
                                                LOAD FROM territories AS source CREATE (n:territory=to_jsonb(source));
                                              
  6. Create indices of vertices for a quick graph search.

    CREATE PROPERTY INDEX ON category(categoryid);
                                              CREATE PROPERTY INDEX ON customer(customerid);
                                              CREATE PROPERTY INDEX ON employee(employeeid);
                                              CREATE PROPERTY INDEX ON "order"(orderid);
                                              CREATE PROPERTY INDEX ON product(productid);
                                              CREATE PROPERTY INDEX ON region(regionid);
                                              CREATE PROPERTY INDEX ON shipper(shipperid);
                                              CREATE PROPERTY INDEX ON supplier(supplierid);
                                              CREATE PROPERTY INDEX ON territory(territoryid);
                                              
  7. Generate edges among vertices.

    LOAD FROM orders_details AS source
                                              MATCH (n:"order"),(m:product)
                                              WHERE n.orderid=to_jsonb((source).orderid)
                                                    AND m.productid=to_jsonb((source).productid)
                                              CREATE (n)-[r:ORDERS {unitprice:(source).unitprice,quantity:(source).quantity,discount:(source).discount}]->(m);
                                              
                                              MATCH (n:employee),(m:employee)
                                              WHERE m.employeeid=n.reportto
                                              CREATE (n)-[r:REPORTS_TO]->(m);
                                              
                                              MATCH (n:supplier),(m:product)
                                              WHERE m.supplierid=n.supplierid
                                              CREATE (n)-[r:SUPPLIES]->(m);
                                              
                                              MATCH (n:product),(m:category)
                                              WHERE n.categoryid=m.categoryid
                                              CREATE (n)-[r:PART_OF]->(m);
                                              
                                              MATCH (n:customer),(m:"order")
                                              WHERE m.customerid=n.customerid
                                              CREATE (n)-[r:PURCHASED]->(m);
                                              
                                              MATCH (n:employee),(m:"order")
                                              WHERE m.employeeid=n.employeeid
                                              CREATE (n)-[r:SOLD]->(m);
                                              

If you have finished all of the steps above properly, the following graph model will be generated. (The visualized results of queries in AgensBrowser can vary depending on the graph layout and/or query conditions)

browser-sample vertex index

05. Querying Graph Data

After loading the Northwind dataset into AgensGraph, check if the data is properly loaded by retrieving it with a Cypher query. For your better and easier understanding, the result of each query run in AgensBrowser is visualized in graph in this tutorial.

  1. Try to retrieve 100 objects from the whole data.
    Query up to 100 objects, including customers, orders, and products:

    MATCH path=(c:customer)-[:purchased]->(o:"order")-[r:orders]->(p:product) 
                                                    RETURN path
                                                    LIMIT 100;
  2. Try to retrieve only the data of a specific customer.
    Query the purchase data of the person named “ANTON” among the list of customers:

    MATCH path=(c:customer)-[:PURCHASED]->(o:"order")-[:ORDERS]->(p:product)-[:PART_OF]->(:category)
                                              WHERE c.customerid = 'ANTON' 
                                              RETURN path
                                              LIMIT 100;
  3. Try to retrieve only the data of a specific product.
    Query the entire order data of a specific product called "Chai" among many products:

    MATCH path1=((:supplier)-[:supplies]->(:product {productname:'Chai'})-[:part_of]->(:category))
                                                MATCH path2=((:customer)-[:purchased]->(:"order")-[:orders]->(:product {productname:'Chai'}))
                                                MATCH path3=((:employee)-[:sold]->(:"order")-[:orders]->(:product {productname:'Chai'}))
                                                RETURN path1, path2, path3; 
                                            
  4. Create a product purchase ranking list per customer.
    Calculate the rating(product-specific order rate) to figure out how often an item ordered by a customer has been purchased:

    DROP ELABEL IF EXISTS RATED CASCADE;
                                                CREATE ELABEL IF NOT EXISTS RATED;
    
                                                MATCH (c:customer)-[:PURCHASED]->(o:"order")-[:ORDERS]->(p:product)
                                                WITH c, count(p) AS total
                                                MATCH (c)-[:PURCHASED]->(o:"order")-[:ORDERS]->(p:product)
                                                WITH c, total, p, count(o) AS orders
                                                WITH c, total, p, orders, orders*1.0/total AS rating
                                                MERGE (c)-[rated:RATED {total_count: to_jsonb(total), order_count: to_jsonb(orders), rating: rating}]->(p);
                                            

    Now that you have created a rating vertex that represents the order rate of each item with the query above, you can inquire the items ordered by “ANTON” and calculate the order rate of each item.

    MATCH path = (c:customer)-[r:RATED]->(p:product)
                                              WHERE c.customerid='ANTON'
                                              RETURN c.customerid as cid, r.total_count, p.productName, r.order_count AS ord_cnt, r.rating, path
                                              ORDER BY cid, ord_cnt DESC
                                              LIMIT 100;
  5. Sort orders for a specific product by "shipping country" with a singleclick (Group By)
    (AgensBrowser 2.1/Enterprise Edition only)

    Using AgensBrowser 2.1 included in the Enterprise Edition package, you can group all the retrieved data by a specific label property (Group By property) with a click of a button. The entire order data (Order) for "Chai", for instance, can be grouped by shipping country (Shipcountry). Please visit Bitnine's website if you need more information on how to install/use AgensBrowser 2.1.
    After querying a graph, click (Filtering & Grouping) from the toolbar on the right side of the AgensBrowser 2.1 screen. A menu for grouping/filtering the vertices that exist in the retrieved data by vertex property will appear. Click a vertex label you want to group and tick a property checkbox you want to group by from the list of properties. Once the selected property is registered in Group By List, click +Group. Now, click Reload to group the currently displayed graph by the selected property.

    ※ Grouping the orders for "Chai" by (Shipcountry) of the (Order) label.

    ※ Order status of "Chai" by (Shipcountry)

  6. Find orders for a product shipped only to a certain country with one click (Filter By)
    (AgensBrowser 2.1/Enterprise Edition only)

    In AgensBrowser 2.1, you can filter the data with a specific label property (Filter By) through a single-button click. For example, here, let's look for orders that were shipped only to the United States from the full orders (Order) for "Chai."
    After querying a graph, click (Filtering & Grouping) from the toolbar on the right side of the AgensBrowser 2.1 screen. A menu for grouping/filtering vertices that exist in the retrieved data by vertex property will appear. Click a vertex label you want to filter and tick a property checkbox you want to use as the filter from the list of properties. Once the selected property is registered in Filter By List, click +Filter and Reload to apply the filtering to the current graph.

    ※ Grouping/filtering by (Shipcountry) is applied simultaneously to the "Chai" order data.

    ※"Chai" orders shipped only to the United States

  7. Explore the shortest distance between vertices with one click (Shortest Path)
    (AgensBrowser 2.1/Enterprise Edition only)

    In AgensBrowser 2.1, you can search for the shortest distance between specific vertices with a single button click. For example, here we are trying to find out the shortest path that a salesperson named "Steven Buchanan" used for sales of meat/poultry food. "Steven" is able to generate sales either by selling the products directly to customers or by reporting customer data to his boss, "Andrew," and assisting him as an indirect contribution to overall sales.
    After querying a graph, click (Find Shortest Path) on the toolbar on the right side of the AgensBrowser 2.1 screen. A window for setting the start vertex (start node) and end vertex (end node) appears. Select the start and end vertices and click Search; the shortest path between the two vertices will be displayed on the screen.

    ※ All the paths existing between "Steven" and ('Meat/Poultry')

    ※ The retrieved shortest distance between "Steven" and ('Meat/Poultry')

    Some may think that the query result in the figure above does not match the graph data shown on the screen. This is because of the Data Overlapping feature provided by AgensBrowser 2.1; using Data Overlapping, the query results can be accumulated on the screen. For instance, the screen above shows the accumulated execution results of two blocks of a query statement, while the query statement displayed on the screen corresponds to the second query block. This is possible since AgensBrowser 2.1 supports two ways of displaying information on the contribution of "Buchanan" to the sales of meat/poultry food.

    ※ Executing one query block and displaying the corresponding result on the screen.

    
                                                MATCH p0=((a:employee)-[:sold]->(:"order")-[:orders]->(:product)-[:part_of]->(:category {categoryname:'Meat/Poultry'})) 
                                                MATCH p1=((a)-[:reports_to]->(:employee)-[:sold]->(:"order")-[:orders]->(:product)-[:part_of]->(:category {categoryname:'Meat/Poultry'})) 
                                                WHERE a.firstname = 'Steven' AND a.lastname = 'Buchanan'
                                                RETURN p0, p1;
                                            

    ※ Executing each of the two query blocks and displaying an accumulation of the results on the screen

    
                                               --First Query Block
                                                MATCH p=((a:employee)-[:sold]->(:"order")-[:orders]->(:product)-[:part_of]->(:category {categoryname:'Meat/Poultry'})) 
                                                WHERE a.firstname = 'Steven' AND a.lastname = 'Buchanan'
                                                RETURN p;
    
                                                --Second Query Block
                                                MATCH p=((a:employee)-[:reports_to]->(:employee)-[:sold]->(:"order")-[:orders]->(:product)-[:part_of]->(:category {categoryname:'Meat/Poultry'})) 
                                                WHERE a.firstname = 'Steven' AND a.lastname = 'Buchanan'
                                                RETURN p;
                                            
  8. Check the graph centrality with one click (Centrality)
    (AgensBrowser 2.1/Enterprise Edition only)

    With AgensBrowser 2.1, you can visualize Graph Centrality with one button click. AgensBrowser 2.1 provides a range of graph centrality criteria including Betweenness, Closeness, Degree, and PageRank. For instance, let's get back to the order data for "Chai" and visualize its centrality. In a screen where Centrality is visualized, the size of each vertex is proportional to the centrality value.
    After querying a graph, click (Centrality) on the toolbar on the right side of the AgensBrowser 2.1 screen. Then, a screen for selecting the Centrality criteria (methods) will appear. When you select a desired criterion, the sizes of vertices in the retrieved graph by Centrality will change; the higher the Centrality value, the larger the vertex size.

    ※ Retrieving all the orders for "Chai" in AgensBrowser 2.1

    ※ Visualizing Closeness Centrality of all order data of "Chai"

    ※ Visualizing PageRank Centrality of all order data of "Chai"

  9. Show neighboring data with one click (Highlight Neighbors)
    (AgensBrowser 2.1/Enterprise Edition only)

    In AgensBrowser 2.1, you can visualize the Neighboring vertex with one button click. (Highlight Neighbors) on the right-side toolbar and select/click a specific vertex. Up to 3-hop neighbor vertices of the clicked vertex will be selected on the screen. The criteria for selecting a neighbor vertex have nothing to do with edge direction. In the case where a duplicate edge label should be selected, however, the vertex connected to that edge is excluded from Neighbor. For instance, in the order data example for "Chai," if you search for Neighbors of an order vertex with Order #10729, the corresponding neighbors will be displayed as shown below. Even if the 10838 order vertex is only 2-hop away from the 10729 order vertex, it already has a Customer vertex "Felipe" as Neighbor, and "Felipe" is linked to the 10729 Order through Purchased edge. For this reason, even if you try to set the 10838 Order as Neighbor, the 10838 Order will not be selected as Neighbor because the Purchased edge is duplicate.

    ※ Displaying Neighbors of an order vertex with ID 10729

  10. Play the graph timeline with one click
    (AgensBrowser 2.1/Enterprise Edition only)

    AgensBrowser 2.1 allows you to visualize the process of creating and changing graphs over time with a single button click.
    After querying a graph, click (Play Timeline) on the toolbar on the right side of the AgensBrowser 2.1 screen. Then, a window for entering the vertex label and the property indicating the time/date of the vertex is displayed. If you want to observe changes of a certain vertex label, the vertex label must have a property representing the time/date (PostgreSQL Date Type). Select a vertex label and a property in the setting window, and click Set Timeline to enable Play button; Time Bar Index will show the start date/time and end date/time of the graph timeline playback. Click Play button to play the Timeline; only a vertex created at each time/date and neighbor vertices of that vertex will be clearly displayed on the screen, while the rest of the data are dimmed. The user can pause the play by pressing Pause or end it by Stop.
    For instance, here, the sales records of (Meat/Poultry) generated by "Steve Buchanan" and "Andrew Fuller" of Sales Team over time are played on a graph.

    ※ Setting the meat and poultry sales timeline of "Steve Buchanan" and "Andrew Fuller"

    A vertex highlighted in white on the timeline play screen below is the vertex created at the time/date, and the ‘activated’ graph data represents 3-hop neighbors of the vertex that is highlighted in white (only 3-hop neighbor vertices with non-duplicate edge label, regardless of edge direction).

06. Updating the Graph

Once you confirm that you can properly retrieve graph data, now try to update it. You may search for the information you need to update the graph data, and then update the values of existing objects or expand the graph.

The following query assigns Janet's reporting target (REPORTS_TO) to Steven; it finds a Steven vertex first through a MATCH query, and then looks for the graph pattern that expresses the past ‘report step’ of Janet; finally, deletes the existing REPORTS_TO edge from this graph pattern, and creates new REPORTS_TO edge between Janet and Steven.

MATCH (mgr:Employee {EmployeeID:5}) -- Steven (vertex)
                                MATCH (emp:Employee {EmployeeID:3})-[rel:REPORTS_TO]->() -- Janet (vertex) and Her/His REPORTS_TO (edge)
                                DELETE rel
                                CREATE (emp)-[:REPORTS_TO]->(mgr);
                                MATCH path0=((emp:Employee {EmployeeID:3})-[rel:REPORTS_TO]->(mgr:Employee {EmployeeID:5}))
                                RETURN path0;

And you may either update or delete the property with SET query as shown below.

MATCH path0=((emp:Employee {EmployeeID:3})-[rel:REPORTS_TO]->(mgr:Employee {EmployeeID:5}))
                        SET emp.country = 'UK'
                        SET emp.notes = null
                        RETURN path0;
                        

※ Changing the Janet's country to the United Kingdom and removing the remarks entry using SET query

In this way, you may change the graph in AgensGraph. If you have any questions on Northwind (dataset) or would like to learn more about AgensGraph, please refer to the link below:

Related Links

Additional Dataset

So far, we’ve been through from importing dataset to AgensGraph to querying and updating loaded graph data, and we can play with another data on the basis of what we’ve learnt; it is time to play with IMDB(Movie Data).