Thank you for your very helpful replies, Riccardo and Scott!
I think I also prefer the reification solution and being fully compliant with the graph model.
From what I've read around the web so far, I've gotten the impression that graph databases are overall better than document databases.
So, from now on, I'll probably usually avoid drawing edges from vertexes to other edges.
And also avoid drawing edges between two edges, which I read elsewhere also isn't appropriate in a graph:
https://github.com/orientechnologies/orientdb/issues/4078http://stackoverflow.com/questions/28781749/am-i-supposed-to-be-able-to-create-edges-between-two-edges-and-or-an-edge-and-aThe rest of this post contains no questions, just info for anyone curious.
Again, I'm a newbie, so, if anyone has any feedback, suggestions, etc., I'd love to read them!
Happily, my renovated, hopefully now compliant graph can now easily be displayed in OrientDB Studio's visual graph editor, just by running the query "select from v".
And I was able to figure out how to write some queries for my renovated graph.
I completed my renovations before seeing Riccardo's second post -
https://groups.google.com/d/msg/orient-database/NDrGteQLmf8/3FKYU9UhBQAJ So, I didn't include a "Concrete" class, just Riccardo's earlier ideas - vertexes of the "Statement" class and edges of classes "Subject" and "Object". Thanks again, Riccardo!
I gave the Statement vertexes two properties: "name", which isn't used in queries and was just for display in my graph screenshot; and "verb", which is the property I used in some queries below.
Example name property from a Statement: "Bob likes Star Trek"
Example verb property from that Statement: "likes"
My renovated graph is now too big for me to easily make an ASCII art version, so, hopefully one or the other of these links will work:
http://astroblahhh.com/files_for_forums/OrientDB_Google_Group/Question_1/OrientDB-Question_1-Expanded_Graph.pnghttps://web.archive.org/web/20150825094101/http://astroblahhh.com/files_for_forums/OrientDB_Google_Group/Question_1/OrientDB-Question_1-Expanded_Graph.pngAnd, here's a DB export in JSON format, for anyone who wants to experiment with the data:
http://astroblahhh.com/files_for_forums/OrientDB_Google_Group/Question_1/apdb.jsonhttps://web.archive.org/web/20150825094433/http://astroblahhh.com/files_for_forums/OrientDB_Google_Group/Question_1/apdb.jsonBelow are a bunch of queries I made. They're largely pretty confusing, both to read and to write, but, this blog post showed me some of the syntax to use:
http://orientdb.com/orientdb-improved-sql-filtering/The official manual also helped:
http://orientdb.com/docs/2.1/SQL.htmlAnd lots of trial and error. :-) Happily, I got much further than I thought I might, being a newbie to graph DBs. :-) (With some familiarity with ordinary MySQL.)
This query gets all the subjects of Statements:
select expand( distinct(out('Subject').name ) ) from Statement(Yields Bob, Joe and Jim.)
All the objects of Statements:
select expand( distinct(out('Object').name ) ) from Statement(Yields "Star Trek", "Bob likes Star Trek", "Star Wars", "Joe's hat", "Jim likes Star Wars", "Jim's cup of tea", "Joe's spoon".)
All subjects who like something:
select distinct(out('Subject').name) from Statement where verb='likes'(Yields "Bob", "Joe", "Jim".)
All subjects who have something:
select distinct(out('Subject').name) from Statement where verb='has'(Yields "Joe", "Jim".)
All the Statements with the subject Joe:
select expand(in('Subject')[@class=Statement] ) from #9:1(Yields "Joe likes Bob's like" (short for "Joe likes the fact that Bob likes Star Trek"), "Joe has a hat", "Joe likes Jim's like" (Joe likes the fact that Jim likes Star Wars), "Joe has a spoon".)
All Statements which say Joe likes something:
select expand(in('Subject')[@class=Statement][verb='likes'] ) from #9:1(Yields "Joe likes Bob's like", "Joe likes Jim's like".)
All Statements which say Joe has something:
select expand(in('Subject')[@class=Statement][verb='has'] ) from #9:1(Yields "Joe has a hat", "Joe has a spoon".)
All the things Joe is stated to have:
select expand(in('Subject')[@class=Statement][verb='has'].out('Object')) from #9:1(Yields "Joe's hat", "Joe's spoon".)
All the things Joe is stated to like:
select expand(in('Subject')[@class=Statement][verb='likes'].out('Object')) from #9:1(Yields "Bob likes Star Trek", "Jim likes Star Wars".)
All the things Jim is stated to like:
select expand(in('Subject')[@class=Statement][verb='likes'].out('Object')) from #9:3(Yields "Star Wars", "Bob likes Star Trek".)
Everyone who likes the fact that Bob likes something:
select expand(in('Subject')[@class=Statement][verb='likes'].in('Object').out('Subject') ) from #9:0(Yields "Joe", "Jim".)
----
Best wishes,
Apollia