Andrea
Andrea

Reputation: 101

NEO4J WEB ADMIN INTERFACE SOME QUESTIONS

I apologize now for my bad English. I'm Italian I'm just using Neo4j for the thesis, but I still have doubts about the multi use. 1) I have created from the web interface, two nodes. I realized that Neo4j has given these indices 0 and 1 (for research). Now suppose that I was wrong and I have to delete the node with index 1 .. Once deleted do I create a new one and the system puts index 2. Practically now the first node with index 0 and the second node with index 2 But I want the second node still has index 1 (basically I want to use the index of the first, as I do?) 2) The same problem with the relationship between two nodes. if I'm wrong to create it, the gate and I create another, I lose the index of the one deleted. 3) If I have to create a relationship between 2 nodes with the double arrow, as I do. I saw that every arrow must have a label, so if I create a relationship between 1 and 2, and a relationship between 2 and 1, you get the double arrow, but with two labels and does not suit me. Thank you for your help sorry for my very bad English

Upvotes: 1

Views: 68

Answers (3)

Mohit
Mohit

Reputation: 311

Q ok. sorry. I return at home today.... Another question. when you create a relationship with a label on the arrow. how do sometime in the future to change the label without delete the relationship? is possible? ANS Yes, You can do that easily you can server for the node and remove label only from the node it will not impact the relation ship , but i will suggest you to assing another one if that was the only label on the node so you can group it properly.

match(n:User{Id:1})
remove n:User set n:DeletedUser
return n

Upvotes: 0

Andrea
Andrea

Reputation: 101

ok. sorry. I return at home today.... Another question. when you create a relationship with a label on the arrow. how do sometime in the future to change the label without delete the relationship? is possible?

Upvotes: 0

Lundberg
Lundberg

Reputation: 111

You should really try to use your own IDs or unique identifier for your nodes, then you can disregard the internal node IDs all together.

If you begin with this Cypher statement in a new database (you only have to set it once),

CREATE CONSTRAINT ON (node:MyNodeLabel) ASSERT node.myid IS UNIQUE

then you can create nodes and relationship like this,

CREATE (a:MyNodeLabel { myid : 0 })
CREATE (b:MyNodeLabel { myid : 1 })
CREATE (a)-[r:RELTYPE]->(b)

or if you do not write the create statements in the same transaction,

CREATE (:MyNodeLabel { myid : 2 })
CREATE (:MyNodeLabel { myid : 3 })

then later,

MATCH (a:MyNodeLabel { myid : 2 }), (b:MyNodeLabel { myid : 3 })
CREATE (a)-[r:RELTYPE]->(b)

or create two nodes and a relationship at the same time

MERGE (:MyNodeLabel { myid : 4 })-[r:RELTYPE]->(:MyNodeLabel { myid : 5 })

You can of course change MyNodeLabel and myid to any identifier you like.

The problem you have with the relationship labels is purely visual or do I misunderstand you?

You know that you can traverse relationships in any direction so maybe you do not need two relationships?

Here is the documentation for Cypher if you have missed it, http://docs.neo4j.org/chunked/stable/.

Upvotes: 1

Related Questions