How to prevent duplicate edges between the same vertices in OrientDB?

I have the top “Face” and the edge “Knows”. Here is a SQL example of how I created it.

CREATE CLASS Person EXTENDS V;
CREATE PROPERTY Person.name STRING;

CREATE CLASS Knows EXTENDS E;

INSERT INTO Person (name) VALUES("John")
INSERT INTO Person (name) VALUES("Ann")
INSERT INTO Person (name) VALUES("Harry")

When I create the line between John know → Ann on

CREATE EDGE Knows FROM (SELECT FROM Person WHERE name = "John") 
TO (SELECT FROM PERSON WHERE name = "Ann") 

he creates it, and everything is in order.

Hpj0q.png

But the problem arises when I accidentally create an edge several times.

5uWxm.png

For relationships, duplicate “Knowledge” is redundant, but for some others, such as “Visited” (John [Visited →] New York), duplicating edges is a desirable feature if the edge of the “Visited” has the “date” property.

I tried to solve this problem by adding a unique index to the "Knowledge" edge, but after that I can create an edge between only one pair of vertices.

.

?

+6
1

EdgeClass [out, in]. edge:

CREATE CLASS Knows EXTENDS E
CREATE PROPERTY Knows.out LINK Person
CREATE PROPERTY Knows.`in` LINK Person
CREATE INDEX Knows.out_in ON Knows (out, in) UNIQUE
+2

All Articles