Hi,
We are currently in the process of evaluating OrientDB and Neo4J for graph database, my task is to prototype the OrientDB while a colleague implements a Neo4J prototype. I'm using the 1.6.3 and have read the entire website + book, running everything on the command line and using SQL syntax to execute queries.
I'm implementing an example of "label" translations. I cannot find a similar example out there to help get it right. Hoping you could put me on the right track. Here is the scenario with complete data script.
Setup:
- I have 3 classes; User, Language and Label.
- Label "is" in a language
- Label "translatesTo" another Label.
- User "speaks" a language (user is only there to complicate things because it has edges to language)
The goal is to start with a label, "Hello" and should find the label "Marhaba". The label 'Marhaba' is not directly linked to "Hello" but in its graph and "Marhaba" is the only one that is linked to language arabic.
Basically, the goal is to start with "Hello", find any other label in its graph that "is" "Language.name" = 'arabic'.
Questions
- how to write such query? is it even possible?
- I'm worried about performance? as it has to start with labels, find all the labels in it's graph and then filter by language. Lets not forget that a label can be the same in multiple languages.
Future Questions :)
Assuming that the previous Question has a solution, I was thinking to also have a count on the edge/link between 2 labels to see how many times it was used. ( I assume it's possible to increment a counter on an edge)
- can the previous query be written to first filter by language and then "order by" the property count of the edge.
for example,
"Hello" is linked to "Bonjour" (french) count: 5
"Hello" is linked to "Salut" (also french) count: 10
When I search for a label in the network of "Hello" in French, I would like to order by the count of the edge. Is that possible?
Thank you in advance.
======================================================================
#drop database if already exists
drop database remote:/locahost/touca root [enter password];
#create touca database
create database remote:localhost/touca root [enter password] local;
#create classes/Vectors
create class User extends V;
create class Language extends V;
create class Label extends V;
#create Links/Edges
create class speaks extends E;
create class is extends E;
create class translatesTo extends E;
#create User Data
create vertex User set name = 'Luca';
create vertex User set name = 'Joe';
#create Language Data
create vertex Language set name = 'En-uk';
create vertex Language set name = 'En-us';
create vertex Language set name = 'Fr-fr';
create vertex Language set name = 'Ru-ru';
create vertex Language set name = 'Ar-sy';
#create Label Data
create vertex Label set name = 'Hello';
create vertex Label set name = 'Salut';
create vertex Label set name = 'Good day';
create vertex Label set name = 'Bonjour';
create vertex Label set name = 'Hallo';
create vertex Label set name = 'Marhaba';
#create the links between the User->Language
create edge speaks from (select from User where name = 'Luca') to (select from Language where name = 'En-uk');
create edge speaks from (select from User where name = 'Luca') to (select from Language where name = 'En-us');
create edge speaks from (select from User where name = 'Luca') to (select from Language where name = 'Fr-fr');
create edge speaks from (select from User where name = 'Luca') to (select from Language where name = 'Ar-sy');
create edge speaks from (select from User where name = 'Joe') to (select from Language where name = 'En-uk');
create edge speaks from (select from User where name = 'Joe') to (select from Language where name = 'En-us');
#create the links between label and language
create edge is from (select from Label where name = 'Hello') to (select from Language where name = 'En-uk');
create edge is from (select from Label where name = 'Hello') to (select from Language where name = 'En-us');
create edge is from (select from Label where name = 'Salut') to (select from Language where name = 'Fr-fr');
create edge is from (select from Label where name = 'Good day') to (select from Language where name = 'En-uk');
create edge is from (select from Label where name = 'Bonjour') to (select from Language where name = 'Fr-fr');
create edge is from (select from Label where name = 'Hallo') to (select from Language where name = 'Ru-ru');
create edge is from (select from Label where name = 'Marhaba') to (select from Language where name = 'Ar-sy');
#create the links between labels
create edge translatesTo from (select from Label where name = 'Hello') to (select from Label where name = 'Good day');
create edge translatesTo from (select from Label where name = 'Hello') to (select from Label where name = 'Hallo');
create edge translatesTo from (select from Label where name = 'Hello') to (select from Label where name = 'Salut');
create edge translatesTo from (select from Label where name = 'Good day') to (select from Label where name = 'Bonjour');
create edge translatesTo from (select from Label where name = 'Bonjour') to (select from Label where name = 'Marhaba');
create edge translatesTo from (select from Label where name = 'Hallo') to (select from Label where name = 'Marhaba');
=======================================================================================