[Neo] Cleaning up relationshiptypes
pd_aficionado at hotmail.com
Sun Apr 25 03:52:56 CEST 2010
I see the deeper issue to the cleanup problem is the fact that it is impossible to list all Relationships of a RelationshipType, which of course has several more use cases.
It's conceivable in certain applications it is desirable to add a certain property to all Relationships of a specific Relationship type.
Certain queries can be made faster when it is possible to iterate over the Relationships of a RelationshipType, especially when the number of instances of that RelationshipType is small compared to the potential number of Nodes that can have such a Relationship.
I have come to realize that Nodes and Relationships are not implemented on equal footing, despite the fact that both are PropertyContainers. The currently provided traversers eg. are Node based, returning a Node iterator, and keeping track of visited nodes, while it is equally conceivable to have traversers that return a Relationship iterator, and keep track of visited Relationships. GraphDatabaseService provides a method to list all nodes but not a method to list all relationships. GraphDatabaseService provides a method to create a node, but it doesn't provide a method to create a relationship. And there are probably other subtle signs that treat Nodes as primary to Relationships.
In the end there are as many reasons to query Relationships as there are reasons to query Nodes, so providing equal facilities to do so would enhance the usability of Neo4J. I haven't looked into the implementation details of Relationships and RelationshipTypes to see if there are severe performance penalties for maintaining additional structure to facilitate the lookup of the Relationships of a RelationshipType, but I will certainly look into it and hope to come up with a reasonable suggestion.
> From: tobias.ivarsson at neotechnology.com
> Date: Sun, 25 Apr 2010 00:19:25 +0200
> To: user at lists.neo4j.org
> Subject: Re: [Neo] Cleaning up relationshiptypes
> The problem with cleaning up RelationshipTypes is that it needs to iterate
> over ALL relationships in the database to ensure that the RelationshipType
> isn't in use. Speeding it up would require storing some sort of structure
> for quickly finding all relationships of a specific type. This hasn't been
> an important enough use case for us to add support for it.
> If you have ideas for how to support this in a good way we would of course
> love to hear about it.
> On Fri, Apr 23, 2010 at 8:49 PM, Niels Hoogeveen
> <pd_aficionado at hotmail.com>wrote:
> > I haven't found any functionality to remove relationshiptypes from the
> > database. Once a relationshiptype is used it seems to remain in the database
> > forever. This may be proper behaviour when relationshiptypes are relatively
> > static, but when relationship types are added dynamically, there can exist a
> > desire to clean-up no longer used relationshiptypes.
> > Let me give an example.
> > I am creating path expressions based upon the metamodel module. For
> > example:
> > Class(article) --> Relationship(author) --> Class(user) --> Property(name)
> > This path expression can be used to traverse from an article to the name
> > property of the user that is the author of the article.
> > The path is stored in the database by taking a cryptographic hash of the
> > string representation of the path, and use that as a relationship type name.
> > Each unique path has a unique string representation. Taking a cryptographic
> > hash of that string representation is for all practical purposes a unique
> > key for that path.
> > The start element of the path will have a property with a key equal to the
> > the cryptographic hash of the string representation of the path (the value
> > is irrelevant), and each step in the path is represented by a relationship,
> > which name is equal to the cryptographic hash of the string representation
> > of the path.
> > These path expressions may come and go in the application. Some may be long
> > lived, others will be removed and never be used again. Over time the
> > database will be polluted with relationshiptypes that are no longer in use,
> > and will probably never be used again.
> > Niels Hoogeveen
> > _________________________________________________________________
> > Express yourself instantly with MSN Messenger! Download today it's FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > _______________________________________________
> > Neo mailing list
> > User at lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> Tobias Ivarsson <tobias.ivarsson at neotechnology.com>
> Hacker, Neo Technology
> Cellphone: +46 706 534857
> Neo mailing list
> User at lists.neo4j.org
New Windows 7: Find the right PC for you. Learn more.
More information about the User