Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-30-2020 12:03 PM
I have just started with Neo4j Graph implementation for a project. I have use case where I cannot keep the same Node Entity on a daily basis for example
I have Travel as main node and Trip as child node.
Every Travel Node is created with List of Trip, and this activity happens on daily basis.
Before end of each day the Trip needs to removed and archived and next day new set of trips are created.
I want to keep the Old trips for analytics and cannot delete them.
What is the best practices to achieve this ?
Should I have another store where I should move the historical trips or is there something that I can manage in Neo4J.
Any guidance on this regard would be of great help.
Michael Hunger suggested the below, but Not sure how to do it via spring data.
You could for instance relabel them, i.e. add an :Old
label or even replace the label with :OldTrip
so they are still around but will not be picked up anymore by your queries.
01-30-2020 02:43 PM
I would like to know if it would make sense to keep the relationships to the travel, not necessary in your Java model but in the graph?
A pragmatic solution that comes to my mind would be something like having a ArchivedTrip
class that has all the field you need for the analysis and provide some kind of copy method in place.
@NodeEntity
public class ArchivedTrip {
// id, fields, constructors, getter, setters
ArchivedTrip of(Trip trip) {
return new ArchivedTrip(trip.getName()....);
}
}
Save the newly created ArchiveTrip
s and remove the Trip
s afterwards from the Travel
.
Important would be to not copy the ids blindly over but create or let the database create new ones. Otherwise you could accedentially override data.
01-31-2020 05:06 AM
Hi Gerrit Meier,
Thank you for your response. Sounds good.
Will this be a a good practice for large data sets for example if ArchivedTrip
grows to few millions. Will this cause any performance issues.
Regards
Rajesh
02-02-2020 11:44 PM
It will definitely not be a good idea to fetch all ArchivedTrip
s with any O(G/R/*)M at once when a certain, something in the thousands, amount is reached.
But for Neo4j it is not a big deal to store this number of nodes.
All the sessions of the conference are now available online