How do we know if an edge is an out() going or in() coming in a graph database like OrientDB? I know that edges serve as links between vertexes (which is the same as a relationship between tables in RDMS), but how do we determine the direction. For example, I have some vertexes for Lecturer and courses, here, I want to have one (1) Lecturer to many Courses i.e. one-to-many relationship. So what is the direction of the edge between a lecturer and Courses, is it in() coming to the lecturer or out() going from a lecturer I mean how do I write the query using "select in() from lecturer" or select out() from lecturer? Thanks.
The direction of an edge is purely related to the domain and does not impact the traversal performance (ie. starting from a vertex, you can traverse incoming edges with the exact same performance as outgoing edges).
The important thing is to define the edge "name" in a meaningful way, so that the edge direction is clear.
I'll try to clarify with an example
Suppose you have two vertex classes: Person and Car. Suppose you want to create a relationship within the two, to represent ownership (ie. a Person owns a Car).
Consider these two ways to represent the relationship:
Person -Owns-> Car
and
Person <-BelongsTo- Car
As you can see, both are clear and represent the domain very well.
Of course you have infinite alternatives to choose the edge name (btw, verbs are typically a very good choice), so you could choose something like "Ownership". This would be a definitely bad choice as it would not make the direction clear, eg.
is it
Person -Ownership-> Car
or is it
Person <-Ownership- Car
Imagine having to do a query on this schema after a few months you don't use it, with tens of relationships that are not semantically clear. You see the problem...
In the end, it's just a matter of how clear the model is. It's a human problem, not a technical problem.
I hope it helps