Anfra docs
Concepts

Datasets

Combine data models into a single, queryable view

A dataset is a container that holds several data models together, along with the join paths between them. It's what agents and dashboards actually query.

Defining a dataset

Dataset sales {
  models: [orders, customers]

  relationship: orders.customer_id -> customers.id

  metric revenue {
    label: 'Total Revenue'
    type: 'aggregate'
    definition: @aql sum(orders.amount) ;;
  }

  dimension order_date {
    model: orders
    definition: @sql {{ orders.created_at }};;
  }
}

Anfra uses the relationship to resolve the join automatically — reports never have to restate it.

What a dataset contains

  • Included models — the tables/entities being combined.
  • Relationships — the join paths between those models.
  • Metrics — named aggregations, which can span multiple included models.
  • Dimensions — reporting fields, pulled from any included model.

Data models vs. datasets

Data modelDataset
RepresentsOne table or queryOne or more joined models
AggregationsMeasures (single-model)Metrics (can span models)
Changes whenThe underlying schema changesReporting needs change

Think of data models as mirroring your database, and datasets as mirroring the questions the business actually asks.

Next steps

On this page