Reputation: 1083
I have a graph containing a bunch of nodes of type "Magazine". Each magazine has a few properties and relationships. I want to add data to the graph on to what extent a magazine is read by a perticular target group, ie "Men" or "Women". Obviously even Magazine targeted to "Women" are sometimes read by "Men" so I can use a property on a relationship (perhaps a number between 0 and 1).
My question is if this is a good design practice as the nodes "Men" and "Women" will have a relationship to every magazine node in the graph. An alternative would be to have a property on the Magazine that holds the value, but this would be less optimal for querying.
Is it ok to have nodes int he graph which basically is mandatory to have a relationship to, or is it just to verbose? If so, what would be a better approach?
Upvotes: 0
Views: 29
Reputation: 19373
Since you have exactly two target groups, the number of relationships from these two would be (# of magazines/2) (from your question, it sounds like a magazine has only one target group, not more). You have not indicated how large your graph is- maybe it's small enough to not cause the two target groups to be dense.
In any case, the question is, what do you intend to do with the target group and the readership%? Will your queries be filtering by them or comparing against them? If not, and these are simply an attributes you wish to capture, then the answer is simple and they should be modelled as properties on the Magazine node.
If you do have a significant number of major queries through these properties, then you could index the property. A separate node per target group would only be valuable if you have more than just two values, magazines can target more than one group, they are related to more than just magazines and they don't become supernodes as @NonameCurious pointed out.
Upvotes: 1
Reputation: 596
I think it depends on how you need to query your data. From what I have experienced with Neo4j, you want to avoid having super nodes with many many edges. But that "many many" is very subjective and may vary depending on the spec of your server. But overall, in your usecase, I think a property would make more sense. Perhaps if you provide some sample queries, we could compare both alternatives.
Upvotes: 1