cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher query : type of id to create relationship between nodes

LJRB
Graph Buddy

Hello, I have a question about ids to create relationship between two nodes.I have this request:

"MATCH (a:ARTICLE),(w:SOURCE) WHERE a.id=$artid AND w.id=$author_id MERGE (a)-[:HAS_SOURCE]->(w)"

Is it possible to give something else than integers as ids ? For example url ? Strings ?
Or are integers mandatory for ids ?

3 REPLIES 3

clem
Graph Steward

Yes you can use either strings or numbers for id's. Obviously, numbers have the advantage of being more compact and faster to compare than strings.

I will note URL's have a canonicalization problem....

HTTP://NEO4.J.COM won't exactly match https://neo4j.com but maybe they should (case and http vs https.)

BUT sometimes case does matter (I really ran into this example in my career).

https://en.wikipedia.org/wiki/Acid (about chemistry) is DIFFERENT from
https://en.wikipedia.org/wiki/ACID (about Computer science)

So, I would try to avoid using URLs as keys. It would be a headache.

thank you @clem and @dominicvivek06 for the answer

Hi @LJRB , the type of id created are also directly related to performance. In my blog -> Neo4j – Relationship Modelling- Performance – Dominic KUMAR's blog I have a demo on the performance.