How to choose between Links and Edges to connect vertices?
Asked Answered
S

2

9

In orientDB, we have links and edges to connect vertices. I can't find out what the cons/pros of each of them on the orientdb documentation.

Forum Example - three entities involved: Author, Message, Forum.

An author writes a message in a forum. - Option one: message is an edge between Author and Forum vertices - Option two: Message has a link to Author and another link to Forum

In other words, what strategy to choose and why?

Scuta answered 16/11, 2015 at 22:14 Comment(0)
E
5

If you don't have properties on your arch you can use a link, instead if you have it use edges.

Erose answered 17/11, 2015 at 8:37 Comment(3)
Thanks! Actually i'd like to know if the performances are the same. in other words, are all the edges automatically loaded when the involved vertices are loaded? is it the same for linklist?Scuta
Another related issue: any Edge can be converted to a Link (or link list) to another Vertex. So is it worth having edges at all? if the answer is no then when to use links and when we really need edges?Scuta
You really need edges if you need to traverse the ralationship in both directions, while using the linklist you can only in one direction.Erose
K
12

Edges are all about connecting vertices. Links are all about relations between other classes.

Two classes may not be associated at all, like a class Oceans and a class Person. But you can have their vertices associated by an Edge named Sailed that may have a property named withShipName`.

So you made a Person vertex called Jack Sparrow, and a Ocean vertex named Atlantic. Then you create an their edge relationship sailed which you can connect like:

Jack Sparrow sailed.withShipName= Black Pearl the Atlantic.

But if you have another Person vertex, like Red riding hood, you don't want to have a link in their vertex properties relating her with an Ocean class.

However, you may want to have a linklist or linkmap linking the class Ocean with class OpticalActiveWaterConstituents, that have vertices to Chorophyll, Suspended Particles, Coloured Dissolved Organic Matter, etc... that are available in all Oceans with different concentrations.

You can refer to this post for the differences between Edges vs LinkList vs Linkmap.

Hope this help to clarify the subject ;)

Kristoferkristoffer answered 20/1, 2017 at 11:1 Comment(0)
E
5

If you don't have properties on your arch you can use a link, instead if you have it use edges.

Erose answered 17/11, 2015 at 8:37 Comment(3)
Thanks! Actually i'd like to know if the performances are the same. in other words, are all the edges automatically loaded when the involved vertices are loaded? is it the same for linklist?Scuta
Another related issue: any Edge can be converted to a Link (or link list) to another Vertex. So is it worth having edges at all? if the answer is no then when to use links and when we really need edges?Scuta
You really need edges if you need to traverse the ralationship in both directions, while using the linklist you can only in one direction.Erose

© 2022 - 2024 — McMap. All rights reserved.