Data visualisation is an important part of the data analytics process. While SQL helps us store, retrieve and manipulate business information, tools like Tableau and Microsoft Power BI help us transform that information into meaningful dashboards and business insights.
In this practical project, we will connect our previously developed Construction Company ERP Database to Tableau Desktop.
Our database represents a fictional US-based construction company that provides three primary services: Construction, Interior Decoration and Architecture Consulting.
The database contains information about employees, clients, projects, quotations, payments, expenses and other business activities.
We have already created the database using MySQL and populated it with dummy business records. Now, our objective is to connect this database to Tableau Desktop and establish relationships between its tables.
Instead of exporting individual CSV files, we will connect Tableau directly to MySQL. This approach allows us to work with the existing relational database and build visualisations using multiple connected tables.
Let’s understand the complete process.
1. Understanding Our Construction ERP Database
Before connecting MySQL to Tableau, we should understand the database structure.
Our Construction ERP database contains ten primary tables:
- Departments
- Employees
- Clients
- Projects
- Project Assignments
- Project Expenses
- Project Payments
- Service Types
- Quotations
- Quotation Items
Each table represents a different business entity or transaction.
For example, the clients table stores customer information, while the projects table maintains information about construction and consulting projects.
Similarly, project_payments records financial transactions received from clients, and project_expenses maintains expenditure information.
These tables are interconnected through primary keys and foreign keys.
This is important because we don’t want to analyse every table independently. We want to combine information from multiple tables to answer business questions.
For example:
- Which clients have generated the highest payment amounts?
- How many projects are currently in progress?
- Which services generate the highest estimated budgets?
- What are the total expenses associated with individual projects?
- How many quotations have been accepted or rejected?
To answer these questions, we need to establish appropriate relationships in Tableau.
2. Open Tableau Desktop
First, launch Tableau Desktop on your computer.
On the opening screen, you will find different options for connecting to data sources.
Tableau supports multiple data sources, including:
- Microsoft Excel
- Text Files
- Microsoft SQL Server
- MySQL
- PostgreSQL
- Oracle
- Google Sheets
Since our database is stored in MySQL, we will use the MySQL connector.
Under the Connect section, locate the To a Server category.
Select MySQL.
If the MySQL connector is not available or Tableau displays a driver-related error, you may need to install the appropriate MySQL database driver.
Once the connector is available, Tableau will open a connection configuration window.
3. Configure the MySQL Connection
After selecting MySQL, Tableau will ask for connection details.
We need to provide the following information:
Server: localhost
Port: 3306
Username: Your MySQL username
Password: Your MySQL password
Database: construction_erp
The server field identifies where the MySQL database is running.
If you are using MySQL on your local computer, localhost is generally the appropriate server value.
The default MySQL port is 3306, although this can be different depending on your configuration.
Enter your MySQL credentials and click Sign In.
Tableau will establish a connection with your MySQL server.
If the connection is successful, Tableau will display the available databases and tables.
4. Select the Construction ERP Database
After establishing the connection, Tableau will display the available database objects.
Select the construction_erp database.
You should now see the tables available within the database.
These include:
- clients
- departments
- employees
- project_assignments
- project_expenses
- project_payments
- projects
- quotation_items
- quotations
- service_types
We can now start building our data model.
5. Drag Tables into the Tableau Data Model
This is one of the most important steps.
In Tableau, select the required tables from the left-side table panel and drag them onto the central data modelling canvas.
Start with the quotations table and then add the projects table.
Continue adding the remaining tables based on their relationships.
For our Construction ERP project, we will connect the following tables:
Client and Project Relationships
- clients
- projects
- quotations
Project Financial Relationships
- project_payments
- project_expenses
Employee Relationships
- employees
- departments
- project_assignments
Quotation Relationships
- quotations
- quotation_items
Service Relationships
- projects
- service_types
When tables are connected through their matching keys, Tableau creates relationships between them.
You will see connecting lines between the tables on the data modelling canvas.
These lines represent the relationships established between the different tables.
6. Establish Relationships Between Tables
Now let’s understand how to establish relationships.
For example, our clients table contains client_id, which uniquely identifies each client.
The projects table also contains client_id, which identifies the client associated with a particular project.
Therefore, we can establish the following relationship:
clients.client_id = projects.client_id
Similarly, we can create other relationships.
| Primary Table | Related Table | Relationship Field |
|---|---|---|
| clients | projects | client_id |
| clients | quotations | client_id |
| clients | project_payments | client_id |
| projects | project_payments | project_id |
| projects | project_expenses | project_id |
| projects | project_assignments | project_id |
| employees | project_assignments | employee_id |
| employees | projects | project_manager_id |
| departments | employees | department_id |
| service_types | projects | service_type_id |
| quotations | quotation_items | quotation_id |
| projects | quotations | project_id |
To configure a relationship, click the connecting line between two tables.
Tableau will display the relationship configuration window.
Select the appropriate matching fields from both tables.
For example:
clients.client_id = project_payments.client_id
Make sure that the selected fields represent the same business identifier.
Repeat this process for the remaining relationships.
7. Understand Tableau Relationships and Joins
An important concept to understand while working with Tableau is the difference between Relationships and Joins.
Although both connect tables, they work differently.
Relationships
Relationships operate at the logical layer of Tableau’s data model.
They allow Tableau to maintain individual tables separately and determine how to combine them based on the fields used in a particular visualisation.
This is particularly useful when working with multiple transactional tables.
Joins
Joins operate at the physical layer.
They combine tables into a single logical table using conditions such as INNER JOIN, LEFT JOIN, RIGHT JOIN or FULL OUTER JOIN.
For our Construction ERP project, we will primarily use Relationships.
Why?
Consider the project_payments and project_expenses tables.
A project may have several payment transactions and several expense records.
If we physically join these tables using project_id, multiple payment and expense records can multiply each other.
This can result in incorrect aggregated totals.
Tableau Relationships help avoid this type of problem by preserving the logical structure of individual tables.
8. Create Client-to-Payment Relationships
One important feature of our Construction ERP database is that the project_payments table contains both client_id and project_id.
This means we can establish a direct relationship between clients and project_payments.
The relationship is:
clients.client_id = project_payments.client_id
We also maintain the relationship:
projects.project_id = project_payments.project_id
This allows us to analyse payment transactions directly by client or through individual projects.
For example, we can create a visualisation showing the total payment amount received from each client.
We can also analyse payments based on projects, payment methods and payment statuses.
Remember that clients should appear only once in the logical model. We can establish multiple relationships from the same table without creating duplicate physical copies.
9. Verify the Data Model
After connecting the tables, review the entire data model.
Check the following:
- Every relationship uses the correct matching columns.
- Primary keys identify unique records in their respective tables.
- Foreign keys reference the appropriate parent tables.
- Relationship cardinality reflects the actual data.
- No unnecessary duplicate tables have been added.
- All required tables are connected to the model.
You can also double-click individual tables to inspect their underlying data and verify that Tableau is reading the records correctly.
Our objective is to create a connected relational data model that allows us to analyse the complete Construction ERP database.
10. Start Creating Visualisations
Once the data model is ready, click Sheet 1 at the bottom of Tableau Desktop.
You will now enter the worksheet environment.
Here, you can use fields from the connected tables to create charts and visualisations.
For example, let’s create a simple client payment analysis.
Drag client_name from the clients table into Rows.
Next, drag payment_amount from project_payments into Columns.
Tableau will automatically aggregate the payment_amount field, generally using SUM.
You will now have a bar chart showing the total payments associated with individual clients.
Similarly, you can create:
- Projects by project_status.
- Expenses by expense_category.
- Quotations by quotation_status.
- Employee distribution by department.
- Payment trends by payment_date.
- Estimated budget by service_name.
These visualisations will become the foundation of our Construction ERP analytics project.
Conclusion
Connecting a MySQL database to Tableau Desktop is an important step in developing a practical business intelligence project.
In this tutorial, we connected our Construction ERP database to Tableau, selected the required tables, established relationships and prepared the data model for visualisation.
We also explored the difference between logical relationships and physical joins and understood why relationships are useful when working with multiple transactional tables.
Our next step will be to create individual worksheets and combine them into interactive dashboards.
By working with this project, we can practically understand how database management, SQL relationships and business intelligence tools work together in a real-world analytics workflow.
Author: Ankit Srivastava
