I have vertex "Person" and edge "Knows". Here is 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 an edge between John knows -> Ann by
CREATE EDGE Knows FROM (SELECT FROM Person WHERE name = "John")
TO (SELECT FROM PERSON WHERE name = "Ann")
it creates it and every thing is ok.
But problem occurs when I accidentially create edge several times.
For the relationship "Knows" duplicates are redundant, but for some other ones like "Visited" (John [Visited ->] New York) duplication of edges are desired feature if edge "Visited" has property "date".
I tried to solve it by adding unique index to edge "Knows", but after that I am able to create edge between only one pair of vertices.
And checking every time edge for existence before creation doesn't seem to me a good idea as well.
How to solve this in correct way?
The straight forward solution is to create an index on EdgeClass[out, in]. To do this, you also have to define the schema for the edge class:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With