Select and insert by keeping references to original data in OrientDB

寵の児 提交于 2019-12-13 06:38:14

问题


I am exploring graphDB query languages. At the moment looking at OrientDB query language. I would like to see how a transaction would look like in OrientDB with the following structure:

Suppose, I have two vertices, A and QA:

CREATE CLASS A EXTENDS V

CREATE CLASS QA EXTENDS V

Class A has a property called p1 of Integer:

CREATE PROPERTY A.p1 integer

Assume that A has three records called a1,a2,a3 with their corresponding values for p1 are a1.p1=2; a2.p1=5; a3.p1=10;:

INSERT INTO A SET p1 = 2            // call this a1
     Created record with RID #11:1   
INSERT INTO A SET p1 = 5            // call this a2
      Created record with RID #11:2   
INSERT INTO A SET p1 = 10           // call this a3
      Created record with RID #11:3    

And assume that I have an edge called isA from QA to A.

CREATE CLASS isA EXTENDS E    // it seems that I can not restrict isA records to connect only QA records to A

I would like to see how the following transaction would look like in OrientDB:

first: select all A's content where p1 < 6 => so I will get {a1,a2}

second: for each element in the first query create an element in QA => so I will get for example {qa1,qa2}

third: Add records to isA Edge such that they connect elements in QA to their corresponding elements in A; =>so, for example connect qa1 to a1 and qa2 to a2.

It seems all three queries are inter-related.

My 1th Question: how the above transaction (i.e., set of inter-related queries) would look like in OrientDB?

Note that elements of A are dynamic (not fixed during my system) and I would like to synch QA elements with A, whenever A's content changes by employing the above transaction; for example, if I add a4 to A with p1=3, and run the above set of queries, I am expecting to get a new record in QA, say qa4 which is linked to a4.

来源:https://stackoverflow.com/questions/29972021/select-and-insert-by-keeping-references-to-original-data-in-orientdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!