简体   繁体   中英

Neo4j (2.2.0): Cypher: Creating Nodes and their IDs

Following is the query i used to build my first node:

MERGE (Precessional_Era_of_Leo:Event:Calendar 
  {Bible:-105
  , Gregorian:-11080
  , Duration:true
  , EndBible:2095
  , EndGregorian:-8880
  , Caption:"Precessional Era of Leo"
  , Weblink:"http://www.aquarian-age.net/flory.html"
  , ImageLink:"http://www.aquarian-age.net/flory.html"
  , Description:"The Precessional Era of Leo (2,200 years)"})
-[:LOCATION 
  {rname:"rlocation"
  , rtype:"from"
  , rleft:"Precessional Era of Leo"
  , rright:"Earth"}]->
(Earth:Planet:Place {Name:"Earth"})
-[:LOCATION 
  {rname:"rlocation"
  , rtype:"In orbit around"
  , rleft:"Earth"
  , rright:"Sol"}]->
(Sol:Star:Place {Name:"Sol"})
-[:LOCATION 
  {rname:"rlocation"
  , rtype:"in"
  , rleft:"Sol"
  , rright:"Milky Way"}]->
(Milky_Way:Galaxy:Place {Name:"Milky Way"})
-[:LOCATION 
  {rname:"rlocation"
  , rtype:"in"
  , rleft:"Milky Way"
  , rright:"Universe"}]->
(Universe:Place {Name:"The Universe"})
-[:LOCATION 
  {rname:"rlocation"
  , type:"in"
  , rleft:"Universe"
  , rright:"GOD"}]->
(GOD:Person:Spirit {Name:"YHWH"});

...and here is the database dump of that same query:

create (_0:`Event`:`Calendar` {`Bible`:-105, `Caption`:"Precessional Era of Leo", `Description`:"The Precessional Era of Leo (2,200 years)", `Duration`:true, `EndBible`:2095, `EndGregorian`:-8880, `Gregorian`:-11080, `ImageLink`:"http://www.aquarian-age.net/flory.html", `Weblink`:"http://www.aquarian-age.net/flory.html"})

QUESTION: Why didn't

Precessional_Era_of_Leo:Event:Calendar

come out as

create (`Precessional_Era_of_Leo`:`Event`:`Calendar`)

instead of

create (_0:`Event`:`Calendar`

...?

Thank you for your responses!

Backticks help escape content that otherwise wouldn't be parsed normally as part of cypher. So if you wanted to name a label "Hello World", (with a space) you can do that, but you'd have to use backticks around the "Hello World".

The bottom line is that the labels you're citing don't need backticks because they don't include any otherwise syntactically invalid cypher. So it doesn't matter whether you use them or not. A label name and the same name surrounded by backticks are functionally equivalent.

In your cypher Precessional_Era_of_Leo is an identifier for the node you are merging. It is not actually a label like Event and Calendar . The identifier is transient to your query whereas the labels are persisted in the database on the node you created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM