Skip to main content
This tutorial requires access to the DirectQuery modules.
This tutorial will walk you through the basics of DirectQuery by creating an application on a external database. We’ll see how to:
  • Use the DirectQuery module in a project
  • Connect to the external database
  • Create a data model based on the external database
  • Use this data model in a Cube
This tutorial requires:
  • A external database
  • Familiarity with this database
  • Familiarity with the basic concepts of Atoti.

Building the external content

Let’s start by generating the content in the external database
Let’s create a new dataset for this tutorial
Then create the sales table and feed it with 20 facts
Let’s create and feed a PRODUCTS table containing information about the products

Importing DirectQuery modules

Additionally to classic Atoti modules you will need to import two modules:
  • One generic module to interact with external databases
  • One to connect to your specific database

Using the external database in DirectQuery

Create the database configuration

Let’s start by creating a connection to BigQuery.
In this example we use a service account and have set an environment variable.
For more details and options about authentication on BigQuery we recommend to follow the official documentation and read the Connect to BigQuery page.
This connection can then be wrapped into an Atoti session.

Add external tables into DirectQuery

The second step is to create the external database schema description.
We start by building the table definition with the help of a external database discoverer.

Create a join between tables

Then we create a join between the tables of our example.
Sales has a many-to-one relationship with Products on the field product_id.

Relationship optionality

When defining a join you can set the Relation Optionality.
The default relationship is Optional, it means that some rows in Sales table could have a product which is missing from the Products table.
You can set this relationship to Mandatory, if you are sure that all products used in Sales table are in Products table.
Mandatory relationship could lead to better performance in some connector features like Incremental refresh.

Create the database

Combining table and join definitions, we can know build our schema and our database around it.

Building an app on the external database

We can now build an ActivePivot on top of this database.
That’s it, the cube is built and you can run queries on it.