You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "titoausten (via GitHub)" <gi...@apache.org> on 2023/05/13 07:53:22 UTC

[GitHub] [age] titoausten commented on issue #918: How to add multiple edges in single query faster?

titoausten commented on issue #918:
URL: https://github.com/apache/age/issues/918#issuecomment-1546589518

   Firstly, you should have a basis for creating edges and should have an idea of the nodes in the graph.
   
   For instance, if you have nodes with labels `Employee`, `Company` and `Role` and you want to add edges between them. Each node should have a property that might be similar to a property in another node.
   
   Now to create edges between nodes with labels `Employee` and `Company`, you simply use the `MATCH` clause. This will look like:
   ```
   SELECT * FROM cypher('graph', $$ MATCH (a:Employee), (b:Company) WHERE a.company = b.name CREATE (a)-[r:worksAt]->(b) RETURN r $$) as (r agtype);
   ```
   To create edges between nodes with labels `Employee` and `Role`, the query will be:
   ```
   SELECT * FROM cypher('graph', $$ MATCH (a:Employee), (b:Role) WHERE a.position = b.name CREATE (a)-[r:IS]->(b) RETURN r $$) as (r agtype);
   ```
   In conclusion, creating multiple edges is dependent on matching properties of nodes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org