Cypher Patterns Quiz

Test your understanding of Cypher patterns before moving on.

Node Label Syntax

Complete the Cypher query to match all Product nodes.

cypher
Find 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

cypher
/* Match all Product nodes */
MATCH (p:Product)
RETURN p.name
LIMIT 5

Relationship Type Syntax

Complete the pattern to match customers who have placed orders.

cypher
Find PLACED relationships
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]→

cypher
/* Find customers who placed orders */
MATCH (c:Customer)-[:PLACED]->(o:Order)
RETURN c.name, o.id
LIMIT 5

Property Filter Syntax

Complete the query to find a customer with a specific ID.

cypher
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).

cypher
/* Find a specific customer by ID */
MATCH (c:Customer)
WHERE c.id = 'ALFKI'
RETURN c.name

Note: Cypher uses = for comparison, not == like some programming languages.

Accessing Node Properties

Complete the query to return the product name property.

cypher
Return the product name
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

cypher
/* Find expensive products */
MATCH (p:Product)
WHERE p.unitPrice > 50
RETURN p.name

Summary

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.

Chatbot

How can I help you today?

Data Model

Your data model will appear here.