2009/11/20 Laurent Laborde <kerdez...@gmail.com>: > On Fri, Nov 20, 2009 at 12:19 PM, Mattias Persson > <matt...@neotechnology.com> wrote: >> 2009/11/20 Mattias Persson <matt...@neotechnology.com>: >>> The best way to achieve that is to create relationships to those >>> nodes... such as >>> >>> ReferenceNode --[CONFIGURATION]--> ConfigurationNode >>> ReferenceNode --[INDEX]--> IndexNode >>> a.s.o. >>> >>> That's more of a neo-style-approach. The node ids persist over time >>> until they are deleted and deleted ids may be reused in the future. >> And I should add: so therefore it's not a good idea to store node ids >> as properties, in any such case use a relationship instead. > > Ok thank you. > So, when i run my app : > - I check if the referenceNode have a relationship of type > "configuration", "index", whatever i want. (traverser depth_one ?) > - if yes, i can retrieve all the info i need on thoses various node. > - if no : i create one of my "system" node. create a relationtype > according type from referencenode to my new systeme node > - and, finally : i do whatever i want with thoses new nodes :) That's right, there's such a utility in the neo-utils component http://components.neo4j.org/neo-utils/ where you do something like:
NeoUtil neoUtil = new NeoUtil( neo ); Node configurationNode = neoUtil.getOrCreateSubreferenceNode( MyRelTypes.CONFIGURATION ); > > The question is : isn't it much more simple to just store nodeID ? :) The algorithm would still be the same woldn't it? o Check to see if we have a "configuration" node (be it checking a property or a relationship, see http://api.neo4j.org/current/org/neo4j/api/core/Node.html#getSingleRelationship(org.neo4j.api.core.RelationshipType,%20org.neo4j.api.core.Direction)) o If not found then create a node o If we created a node then connect it with the reference node (be it via property or createRelationship) And as we mentioned earlier it's not a good practice to rely on node IDs. > > -- > Ker2x > _______________________________________________ > Neo mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Neo Technology, www.neotechnology.com _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user