OrientDB : Edges vs LinkList vs Linkmap

后端 未结 2 1963
天命终不由人
天命终不由人 2021-02-09 06:32

What are the pros and cons for using either a linklist, a linkmap or an edge to store relationships between my vertices ?

2条回答
  •  清歌不尽
    2021-02-09 06:55

    Quite a bit late for arrival, but I was looking for this answer recently and figured it out a bit clearly.

    Links in OrientDB provides the equivalent of foreign-key relations in the relational database world. If you consider tables as classes then the link connects between two classes

    In their 3.0 manual under http://orientdb.com/docs/3.0.x/sql/SQL-Introduction.html and No JOINS section, they state

      SELECT * FROM Employee WHERE city.country.name = 'Italy'
    

    What they do not tell you at that point in the manual is that these are from linked tables and not from graph relations.

    For this to work in the Graph technique, first you will need to create an edge. I would label that like locatedIn so

      Employee => `locatedIn` => City
    

    And also edges from the City records

     City => `ofCountry` => Country
    

    Then the graph based OrientDB query might be.

     SELECT * FROM Employee WHERE out(“locatedIn”).out(“ofCountry”) = “Italy”
    

    You might think, this looks a lot more complicated. And it is. But just say at some point later another Edge relation named salesTerrotiryfor this employee was added by someone else then this can be Traversed and discovered like this

     TRAVERSE * FROM Employee MAXDEPTH = 2
    

    And in there you will find that the new salesTerritory edges will be found. This is where the ad-hoc relationship discoveries to almost any depths are super easy with a Graph DB. Should you have implemented this in a relational database, you will need to explore the schema for new FKs. Doable, but a lot more complicated.

提交回复
热议问题