简体   繁体   English

OrientDB : Edges vs LinkList vs Linkmap

[英]OrientDB : Edges vs LinkList vs Linkmap

什么是使用一个利弊linklist ,一个linkmapedge到我的顶点间商店关系?

An edge defines a relationship between two vertices.边定义了两个顶点之间的关系。 For example, you define two vertices, Person and Car.例如,您定义两个顶点,Person 和 Car。 You then define an Edge Drives.然后定义一个边缘驱动器。 This edge ties the two vertices together.这条边将两个顶点连接在一起。 "Jane" Drives "Ford". “简”驾驶“福特”。

A linklist is a list of classes associated with another class.链接列表是与另一个类关联的类的列表。 A Car class might have a linklist of parts from the Part class. Car 类可能有来自 Part 类的零件的链接列表。 A car consists of multiple parts.一辆汽车由多个部分组成。

A linkmap is a map of key, class values associate with another class.链接映射是键的映射,类值与另一个类相关联。 A car class might have a linkmap of PartType, Part.汽车类可能具有 PartType、Part 的链接图。 A car consists of multiple parts, which can be grouped by engine, body, chassis, etc.一辆汽车由多个部分组成,可以按发动机、车身、底盘等进行分组。

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. OrientDB 中的链接提供了关系数据库世界中的外键关系等价物。 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 statehttp://orientdb.com/docs/3.0.x/sql/SQL-Introduction.html和 No JOINS 部分下的 3.0 手册中,他们声明

  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我会把它标记为locatedIn所以

  Employee => `locatedIn` => City

And also edges from the City records还有来自城市记录的边缘

 City => `ofCountry` => Country

Then the graph based OrientDB query might be.那么基于图的 OrientDB 查询可能是。

 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 salesTerrotiry for this employee was added by someone else then this can be Traversed and discovered like this但是只是说在某个时候,其他人为该员工添加了另一个名为salesTerrotiry Edge 关系,然后可以像这样遍历和发现

 TRAVERSE * FROM Employee MAXDEPTH = 2

And in there you will find that the new salesTerritory edges will be found.在那里您会发现将找到新的salesTerritory边缘。 This is where the ad-hoc relationship discoveries to almost any depths are super easy with a Graph DB.这是使用 Graph DB 可以非常轻松地发现几乎任何深度的临时关系的地方。 Should you have implemented this in a relational database, you will need to explore the schema for new FKs.如果您已经在关系数据库中实现了这一点,您将需要探索新 FK 的架构。 Doable, but a lot more complicated.可行,但要复杂得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM