Relationship Tense


(Paulgiblin) #1

I'm new to graph databases, so please forgive me if the answer to this is obvious. In all the examples I've seen, relationships have a verb to describe them (such as employee WORKS_AT company). Is it common practice to use present tense and modify the relationship manually later on if the relationship changes? Or would it be better practice to create a second parallel relationship? Or would it be better still to use a property to describe the tense?


(Ameyasoft) #2

Relationship types and node labels are case, tense independent and you are free to use anything. Also, one can change the relationship type using APOC library. Here is how:

CREATE (f:Foo)-[rel:WORKING]->(b:Bar)
We can change the relationship type from WORKING to WORKED

MATCH (f:Foo)-[rel:WORKING]->(b:Bar) with rel
CALL apoc.refactor.setType(rel, 'WORKED') YIELD input, output RETURN *

Result will be (f:Foo)-[rel:WORKED]->(b:Bar)