Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-27-2019 06:47 PM
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
03-27-2019 11:47 PM
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:
Doe2 is now the current owner of phone 12345.
03-27-2019 11:59 PM
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.
03-28-2019 10:41 AM
Check these two links:
All the sessions of the conference are now available online