Module 1

Understanding Aggregation in Cypher

Module overview

Full definition for aggregation (opens in a new tab)Grouping rows and computing a value over each group. In Cypher the grouping keys are whatever expressions in the same clause are not aggregated. in Full definition for Cypher (opens in a new tab)Neo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. means that during a query, the data retrieved is collected or counted. The aggregation of values or counts are either returned from the query or are used as input for the next part of a multi-step query. If you view the execution plan for the query, you will see that rows are returned for a step in the query. The rows that are returned in a query step are an aggregation of Full definition for property (opens in a new tab)A named value stored on a node or a relationship. values, Full definition for node (opens in a new tab)A vertex in a graph. In a property graph it can carry labels and properties., Full definition for relationship (opens in a new tab)A named, directed connection between two nodes. Every relationship has a type, a start node and an end node., or paths in the graph. There are some best practices for aggregating data during your query that you can better understand with examples and explanations of how the query works at runtime.

In this module, you will learn how aggregation works at runtime when using:

Data model for this course

This course uses the recommendations dataset for all the queries you will be running and writing. This is the same dataset that will be used for the application development courses in GraphAcademy.

Here is the Full definition for data model (opens in a new tab)The labels, relationship types and properties chosen to represent a domain.:

Movie Data Model,width=600,align=center

You can view the data model in the sandbox to the right by executing this query:

cypher
CALL db.schema.visualization()

The node Full definition for label (opens in a new tab)A tag on a node that groups it with other nodes of the same kind. A node can carry more than one. for the graph include:

  • Person
  • Actor
  • Director
  • Movie
  • Genre
  • User

The relationships for the graph include:

  • ACTED_IN (with an optional role property)
  • DIRECTED (with an optional role property)
  • RATED (with rating and timestamp properties)
  • IN_GENRE

Also notice that the nodes have a number of properties, along with the type of data that will be used for each property. It is important that you understand the property types defined in the data model.

You can view the property types for nodes in the graph by executing this query:

cypher
CALL db.schema.nodeTypeProperties()

You can view the property types for relationships in the graph by executing this query:

cypher
CALL db.schema.relTypeProperties()

Resources

During this course, you can refer to:

Ready, let's go!