On Tue, May 6, 2008 at 10:02 AM, Philip Jägenstedt <[EMAIL PROTECTED]> wrote: > Hi again, > > I was going to hear with you all about best practices for dealing with > what can be described as "fragile typing": Given the relationship > REMIXED going out from an artist, it's possible that the target node > is either and album or a single track. How do I solve this? > > 1. Use two relationships REMIXED_ALBUM and REMIXED_TRACK. This will > actually end up creating *very* many extra relationships in my case, > but that may not be a problem. > > 2. Set a targetType property on the relationship. > > 3. Set a entityType property on the target node. > > In general, I know what kind of node I am dealing with by looking at > the path I traversed to get to it. But given any random node, I > currrently couldn't tell. This isn't so much a problem, but when > dealing with relationships that may have different kinds types of > targets it gets to be a bit messier. I'm certain you've thought a bit > about this problem, so could you share the pros and cons of the > methods I've suggested above. Are there other solutions? > > Philip
Another solution is to have a relationship (ex. IS_A or INSTANCE_OF) from the entity node to a node describing the type. I recommend designing the node space so you can determine what a random node really is by looking at the relationships it has (or a combination of relationships and properties). Having the two different relationship types will result in better performance getting all the albums or all the tracks given an artist. Performance for getting any album or track given an artist will be about the same. The drawback with this solution is that the code needs to manage an additional relationship when performing operations that deals with the connection between an artist node and a track/album node. -Johan _______________________________________________ Neo mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

