Test your understanding of Cypher patterns before moving on.
Node Label Syntax
Complete the Cypher query to match all Product nodes.
MATCH (p/*select::Product*/)
RETURN p.name
LIMIT 5-
❏ .Product
-
✓ :Product
-
❏ @Product
-
❏ Product:
Hint
Labels in Cypher patterns use a colon prefix before the label name.
Solution
The correct syntax for a label is :Product.
Labels always use a colon prefix: :LabelName
/* Match all Product nodes */
MATCH (p:Product)
RETURN p.name
LIMIT 5Relationship Type Syntax
Complete the pattern to match customers who have placed orders.
MATCH (c:Customer)-/*select:[:PLACED]*/->(o:Order)
RETURN c.name, o.id
LIMIT 5-
❏ -:PLACED→
-
❏ -PLACED→
-
✓ [:PLACED]
-
❏ -[PLACED]→
Hint
Relationship types are written inside square brackets with a colon prefix.
Solution
The correct syntax for a relationship type is [:PLACED].
Relationship types use square brackets with a colon prefix: -[:TYPE]→
/* Find customers who placed orders */
MATCH (c:Customer)-[:PLACED]->(o:Order)
RETURN c.name, o.id
LIMIT 5Property Filter Syntax
Complete the query to find a customer with a specific ID.
MATCH (c:Customer)
WHERE c.id /*select:=*/ 'ALFKI'
RETURN c.name-
❏ ==
-
✓ =
-
❏ :
-
❏ IS
Hint
Cypher uses a single equals sign for comparison in WHERE clauses.
Solution
The correct operator for equality in WHERE clauses is = (single equals sign).
/* Find a specific customer by ID */
MATCH (c:Customer)
WHERE c.id = 'ALFKI'
RETURN c.nameNote: Cypher uses = for comparison, not == like some programming languages.
Accessing Node Properties
Complete the query to return the product name property.
MATCH (p:Product)
WHERE p.unitPrice > 50
RETURN p/*select:.name*/-
❏ →name
-
✓ .name
-
❏ [name]
-
❏ :name
Hint
Properties are accessed using dot notation, similar to many programming languages.
Solution
The correct syntax to access a property is .name (dot notation).
Properties use dot notation: variable.propertyName
/* Find expensive products */
MATCH (p:Product)
WHERE p.unitPrice > 50
RETURN p.nameSummary
Great work! You can now identify the correct syntax for:
-
Node labels (
:Label) -
Relationship types (
[:TYPE]) -
Property filters in WHERE clauses
-
Returning node properties
In the next lesson, you will learn how to identify what should be a node in your graph model.