orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.72k stars 870 forks source link

Improve graph in and out relationships by using multiple SETs [moved] #781

Closed lvca closed 9 years ago

lvca commented 11 years ago

This is Issue 781 moved from a Google Code project. Added by 2012-04-13T08:26:22.000Z by l.garu...@gmail.com. Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Low, v2.0.0

Original description

In order to improve performance on large relationships a best practice would be to separate them in multiple sets. Example:

StudentVertex:
 outCourses ->* CourseVertex
 outProfessors ->* ProfessorVertex
 outAddresses ->* AddressVertex

And CourseVertex will have:
 inStudent ->* StudentVertex

In this way to get all the professors of a student just retrieve the outProfessors edges. 

To avoid to let to the OrientDB user the responsibility for right naming (yes, it's pretty error prone basing this on naming conventions) the user could use the new model called "TypedGraph" that will do all the work transparently based on vertex/edge classes. The class name could be OTypedGraphDatabase with these new features:

- change OGraphDatabase.getOutEdges() and getInEdges() to consider all the sets that starts by "out" and "in" all together as a unique set. For example "out" and "outProfessors" as outEdges and "in" and "inInvoices" for inEdges. This will maintain the compatibility with higher-level layers like TinkerPop Blueprints
- The method OGraphDatabase.createEdge() will use the edge's class name to know where to place the edge. For example if you've the Edge class name Knows it will add the new edge in Vertex1.outKnows and Vertex2.inKnows
- The Edge could contain the properties "outAs" and "inAs" to specify in what property has been created. If not exists out/in is assumed and this maintain the compatibility with the previous graphs and TinkerPop Blueprints model.
lvca commented 9 years ago

We implemented this in 1.4