Skip to main content

Getting started with DirectQuery

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 connector

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 used to create a DirectQuery connector.

Add external tables into DirectQuery

The second step is to create the external database schema description.
We start by building the table definition. This can be done either with the help of an external database discoverer or by manually building the description of the tables.
Let’s first create a discoverer from the connector. Note that there are settings for the discoverer to customize the behavior but in this example we will use the default ones.
Now we want to create the tables for our application, by discovering their structure on the external database.
For more information about creating table manually without discovery read the Create tables page.

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 schema

Combining tables and join definitions, we can now build our schema description.

Building an app on the external database

We can now build an Atoti cube manager description as usual.
Then create the DirectQuery application.
That’s it, the cube is built and you can run queries on it.