2017-07-24 34 views
0

我「M manipulatig文檔集合和邊緣集合,我想執行一個連接opperation從文檔中收集 這裏得到dettails就是我試圖去OrientDB追加場進行加入

第一:select from l2 where p = "568700933" 的加入其他集合屬性有一個值p = 568700933;

select Entry from P where reference = p+";"

和第三返回條目和頁。

我不知道如何加入此

當我嘗試select from a , b我得到一個錯誤

任何幫助將不勝感激

我需要的是:

Select from edge node of key p = "568700933" , get the assosiated details from the document collection of the same key , knowing that the document collection had p = "568700933;" 

回答

1

有在OrientDB中沒有加入,你不能這樣做。查詢只接受一個目標。

在圖形數據庫中,您將關係定義爲邊,而不是pk/fk和連接。 一旦你有你的邊緣,你可以使用SELECT與out()/in()功能或MATCH遍歷他們(http://orientdb.com/docs/2.2.x/SQL-Match.html

[編輯]這裏是如何與OrientDB做一個實際的例子。

假設你有兩個頂點類ClassPClassQ和和邊緣類稱爲ClassE

首先,讓我們創建的模式:

CREATE CLASS ClassP EXTENDS V; 
CREATE CLASS ClassQ EXTENDS V; 

CREATE CLASS ClassE EXTENDS E; 

現在讓我們用一些數據來填充它:

CREATE VERTEX ClassP SET name = 'foo'; 
CREATE VERTEX ClassP SET name = 'bar'; 

CREATE VERTEX ClassP SET id = 1; 
CREATE VERTEX ClassP SET id = 2; 

並通過邊緣連接它們:

/* from "foo" to "1" */ 

CREATE EDGE ClassE 
FROM 
    (SELECT FROM ClassP WHERE name = 'foo') 
TO 
    (SELECT FROM ClassQ WHERE id = 1) 
SET myEdgeProp = 'x'; 


/* from "foo" to "2" */ 

CREATE EDGE ClassE 
FROM 
    (SELECT FROM ClassP WHERE name = 'foo') 
TO 
    (SELECT FROM ClassQ WHERE id = 2) 
SET myEdgeProp = 'y'; 


/* from "bar" to "2" */ 

CREATE EDGE ClassE 
FROM 
    (SELECT FROM ClassP WHERE name = 'bar') 
TO 
    (SELECT FROM ClassQ WHERE id = 2) 
SET myEdgeProp = 'z'; 

現在,我們可以查詢數據集如下:

/* get the name of a vertex and all the connected IDs */ 

SELECT name, out("ClassE").id FROM ClassP WHERE name = 'foo'; 

MATCH 
    {class:ClassP, as:a, where:(name = 'foo')} -ClassE-> {as:b} 
RETURN a.name as name, b.id as id 

/* return all the details for all the vertices */ 

MATCH 
    {class:ClassP, as:a, where:(name = 'foo')} -ClassE-> {as:b} 
RETURN $elements 

我希望它能幫助

+0

又是什麼的aport多模型數據庫?如果我們不能同時處理文檔和圖表?所以不可能測試它有多快我只是總結文檔查詢和圖形查詢的時間然後求和? –

+0

恐怕我不明白你的意思...... JOIN不是文檔模型的操作......你不需要對文檔和圖形進行單獨的查詢,只需編寫一個簡單的MATCH查詢和返回所有你需要的 –

+0

如果不是加入,那麼它是什麼,我可能會錯誤地使用該術語。我編輯了排隊,說我需要得到的希望,你會幫助它 –