The time attributes

Hello ,i want to ask a question, do you add time attributes when building maps? After all, some relationships will change with time, such as a customer connecting to a mobile phone number, but after a year, this user may cancel this number, this number becomes someone else. If this relationship is large, how should you update it?

Thanks

Simplest is to add a property, "current" to the Owner node and set that to "Yes" for the current owner and "No" to the previous owners. If you need to store the from and to dates you add them as properties. No need to add this date info if you are not going to use them in any of your queries.

Here is a sample:
Create Phone and Owner nodes:

MERGE (p:Phone {number: "12345"})
MERGE (o:Owner {name: "Doe", current: "Yes"})
MERGE (p)-[:OWNER]->(o)
RETURN p, o;

Adding a new owner:

//Select the Owner where current = "Yes"

MATCH (a:Phone)-[:OWNER]->(u:Owner)
WHERE a.number = "12345" and u.current = "Yes"
SET u.current = "No"

//Add the new Owner:

MERGE (o:Owner {name: "Doe2", current: "Yes"})
MERGE (a)-[:OWNER]->(o)
RETURN a, o;

Result:

setno

Doe2 is now the current owner of phone 12345.

First of all, thank you for your answer

but there is still a problem. If it accumulates over a long period of time, it may not change much in a year, But if it accumulates over a long period of time, then the amount may be a little large. Although the number of mobile phones will not change for a long time, it is only an example. There may be something else, such as a device, which is likely to be sent to others. So Click In your way, if you accumulate it over a long period of time, there will be a lot of connections between the points. In addition, if many customers'devices are replaced, it will be inefficient to update the status one by one.

My main idea is to set time as an attribute of a relationship, but the main question is how to update it better.

Check these two links:

https://medium.com/neo4j/graph-versioning-episode-one-time-based-564ac897c59e