Why do we have both ' & ` as text identifiers

I am running the below practice code from graph academy and noticed that the code has movie name in forward quotes i.e. 'Hoffa' while the custom output column name in backward quotes i.e. Year Born , though both are text characters. I tried using the same forward quote (as in most programming languages)for both but it failed, throwing error for output field. I am wondering whats the logic behind having two separate style quotes.

MATCH (p:Person)-[:ACTED_IN]-(m:Movie)
WHERE m.title = 'Hoffa'
RETURN p.name AS Actor, p.born as Year Born ORDER BY p.born DESC LIMIT 1

Enclosing strings in back ticks allows you to use strings with spaces for variable names or aliases. In you example above, 'year born' is an alias for p.born. String literals can be enclosed in either single or double quotes.

2 Likes

Thank you Gary for the clarification. Just curious why single or double quotes were not chosen for specifying names or aliases with spaces.

I guess because it gives the parser the ability to differentiate between variable names and literal strings.

1 Like