Documentation
Syntax
Aggregation

Aggregation expression

The syntax to define an aggregation -a virtual entity- uses the aggregation keyword, followed by the name of the aggregation and the name of the relationship to be aggregated surrounded by parenthesis. The following example defines an aggregation named "Human_drinks_coffee" that aggregates the "Drinks" relationship:

entity Human {
  id key
  name
  age
}
 
entity Coffee {
  id key
  species
  roast_date
}
 
relation Drinks(Human, Coffee 1) {
  amount
}
 
aggregation Human_drinks_coffee(Drinks)

The visualization of the aggregation:

aggregation ER Diagram

Aggregations can be used just as an entity in relationships, identifying them by their name. The following example shows an aggregation participating in a relationship:

entity Library {
  name key
  address key
}
 
entity Book {
  bid key
  name
  n_pages
}
 
entity Author {
  id key
  name
  language
}
 
relation Writes(Author, Book 1!) {
  took
}
 
aggregation Book_written_by_Author(Writes)
 
relation Contains(Library, Book_written_by_Author 1)
aggregation participating in relationship ER Diagram