Group relations

21 views
Skip to first unread message

nicolas treiber

unread,
Apr 13, 2017, 2:02:19 PM4/13/17
to OrientDB
Hi.
I have a problem with a query which consumes a lot of memory. 
Let's imagine I have the following data :
I have a Type class with two vertices: Vegetal, Animal
I have a class Species: Tree, Flower, Firefox, Panda, Elephant
A class Color: Brown, Yellow, Orange, White, Black, Green, Gray

those nodes a connected that way: 
Vegetal -> Tree and Flower
Animal to Firefox, Panda and Element
Tree to Brown and Green
Flower to Green and Yellow
Firefox to Orange
Panda to Black and White
Elephant to Gray

What i'd like to do is to get all the data of each Type nodes with their Species and the Colors of the Species, with prefixes (i need the prefixes for post operations)
For now what I do is: SELECT t.* as t_, s.* as s_, c.* as c_ from (MATCH {class: Type, as t}-->{class: Species, as: s}-->{class: Color, as: c} return t, s, c)
but the more relations there is, the entries I get (in the example above, i would end up with 8 entries with all the data each time). What i'd like to get is one entry per Node and one entry per match. Something like that:
- Data of Vegetal
- Data of Animal
- Data of Tree
- Data of Flower
- Data of Firefox
- Data of Panda
- Data of Elephant
- ... (same for each colors)
- one entry for t: Vegetal s:Tree c:Brown
- one for t:Vegetal s:Tree c:Green
- t:Vegetal s:Flower c:Green
- ...

I'd end up with more entries but much less data because the entries for relationships would only contain RIDs.

Any idea on how to do that ?

Luigi Dell'Aquila

unread,
Apr 15, 2017, 12:01:14 PM4/15/17
to orient-...@googlegroups.com
Hi Nicolas

I'm not sure I understood the data format you expect as a result:

ex 1:

vegetal, tree, green
vegetal, tree, brown
vegetal, flower, green
vegetal, flower, yellow

ex 2:

vegetal, tree, [green, brown]
vegetal, flower, [green, yellow]

or anoother one?

Thanks

Luigi



--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages