Hi there,

I'm trying to approach OrientDB, coming from relational background.

I've already looked at 
this: 
http://www.orientechnologies.com/docs/last/orientdb.wiki/Import-RDBMS-to-Graph-Model.html

However, I'm not sure how I would do this when I start from a many-to-many 
relationship.

*Example (term-doc matrix as used in information retrieval - which term 
occurs in which document)*

-- all terms
CREATE TABLE term (id INTEGER, term STRING);
INSERT INTO term VALUES (0, 'OrientDB');
INSERT INTO term VALUES (1, 'is');
INSERT INTO term VALUES (2, 'cool');

-- all docs
CREATE TABLE doc (id INTEGER, title STRING);
INSERT INTO doc VALUES (10, 'manual');
INSERT INTO doc VALUES (11, 'license');

-- many-to-many relations
CREATE TABLE term_doc (term_id INTEGER, doc_id INTEGER);
INSERT INTO term_doc VALUES (0, 10);
INSERT INTO term_doc VALUES (0, 11);
INSERT INTO term_doc VALUES (1, 10);
INSERT INTO term_doc VALUES (2, 10);

*First question:*
With OrientDB, turning the term and the doc records into Vertex records is 
easy. No problem there.
How could I take the content of term_doc and create the respective edges? 
Can this be done in the OrientDB SQL console?


*Second question:*Supposing I have solved the first issue, and I want to 
count how many times each term appears in each document.
In relational, this would be:
SELECT term_id, doc_id, count(*)
FROM   term_doc
GROUP  BY term,doc;

Now, I suppose this is not how you would do it once you have modeled the 
term-doc problem into a graph database. Also because when I tried to do run 
this query against a simple import of term_doc, it was incredibly slow.
So, supposing I have real edges between term and doc, instead of the 
explicit table term_doc, how could I obtain the count I mention above?

Thanks!
Roberto

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to