I'm starting to use neo4j.
In my graph database I've the nodes Person
(look at "John" below), with the labels: Name
(string), Food
(positive integer). Each Person
is connected with other Person
through the relationship isFriendTo
, that has a value.
I use the graph DB only to find the shortest weighted path between two person.
Also, every day I check every node in the graph, and if the food go under value of 100, I take some actions.
Now, after some improvements, the property Food
is no more enough for my project. So I have to split this in three other more specific property (positive integer): Vegetables
, Meat
and Cereals
. If the sum of both three go under 100, I've to take the same actions as before.
My old situation was as "John", the only options to which I can evolve my design is to "Fred" or "Paul"?
In which way can I design this? Should I use in addition to neo4j something like MongoDB to represent hierarchy?
Removing the property Food and add the three new properties seems like a bad practices to me. I've to save elsewhere that this 3 means "food"... and what about if in the future will I add others types of foods? Where do I store the knowledge that the value 100 to check, must come from the sum of Meat
, Vegetables
and Cereals
?
Having something like this, will solve my doubt because I can sum all items inside food
:
{
"name": "Lucas",
"food": {
"meat": 40,
"vegetables": 30,
"cereals": 0
}
}
(I don't need to traverse the connections from Food
and Vegetables
to Person
. Just need to check that the sum of Meat, Veg. and Cereals is lesser or greater 100.)