Learning Bold BI Dashboard Embedding with Multi‑Tenant Data Architecture – Part 2: Same Database with Separate Schemas per Customer
Introduction
Modern SaaS applications are designed to serve multiple customers (organizations) from a shared infrastructure while ensuring that each customer’s data remains isolated and secure. One commonly adopted approach to achieve this is a schema‑based multi‑tenant data architecture, where all customers share a single database, but each customer’s data is stored in a separate schema.
In this model, the application identifies which customer is logged in and dynamically accesses the corresponding schema within the same database. The same architectural principle must be applied to analytics and reporting so that each customer can view only their own data, even when dashboards are shared.
This Knowledge Base explains:
- How SaaS applications store multi‑tenant data using separate schemas within a single database
- How this data architecture is reflected in analytics
- How Bold BI can consume this architecture to create one reusable dashboard while ensuring schema‑level data isolation
Important: In the previous part of this series , we explored a multi‑tenant data architecture where each customer’s data is stored in a separate database. In this article, we focus on another commonly used SaaS pattern: a schema‑based multi‑tenant data architecture, where all customers share a single database, but each customer’s data is isolated within a dedicated schema.
Multi‑Tenant Database Architecture Explained
In a schema‑based multi‑tenant SaaS setup, a single organization (for example, Bold Corp) hosts one database server with a single database named sales_analysis_db. Within this database, separate schemas are created for each customer.
Example structure:
sales_analysis_db.alpha_electronicssales_analysis_db.beta_enterprisesales_analysis_db.gamma_industriessales_analysis_db.delta_industries
Each schema:
- Belongs exclusively to one customer
- Uses the same table structure (tables, columns, relationships)
- Is logically isolated from other customer schemas
Although all customer data resides in the same database, data isolation is enforced at the schema level, allowing each tenant to operate independently.
Building a Unified Sales Analysis Dashboard
In the Bold Corp SaaS model, customers such as Alpha Electronics, Beta Enterprise, Gamma Industries, and Delta Industries use the same application. All tenant data is stored in the same database (sales_analysis_db), but each customer’s data exists in a dedicated schema.
The business requirement is to:
- Build one unified Sales Analysis dashboard
- Embed the dashboard into the Bold Corp application
- Ensure each logged‑in customer sees only data from their own schema
This must be achieved without creating multiple dashboards, without duplicating datasets, and without changing the dashboard design per customer.
Key Challenge: Static Data Source Configuration
When creating a data source in Bold BI, connection information such as the following must be provided:
- Server name
- Database name (
sales_analysis_db) - Schema name
- User name
- Password
By default, these values are hard‑coded at design time.
If a static configuration is used:
- The dashboard becomes tightly bound to one schema
- Separate dashboards or data sources are required for each customer
- Managing schema‑specific dashboards becomes unscalable
This directly conflicts with the goal of build once, reuse everywhere.
Bold BI Solution: Custom Attributes for Dynamic Schema Resolution
Custom Attributes: Introduction
Let us begin by understanding the concept of a custom attribute.
A custom attribute refers to a parameter that operates as a segment of code, which users can substitute within queries, custom expressions, or the Data Source Connection interface. These attributes are individually stored for each user and dynamically utilized to render dashboards.
Custom attributes can be configured at three hierarchical levels:
- User Level
- Group Level
- Site Level
The user-level attribute holds the highest priority, superseding the other levels. Attributes defined at the group and site levels can be overridden by those specified at the user level. Moreover, group-level attributes have the capability to override site-level attributes.
For a comprehensive understanding of custom attributes and their practical applications, please consult the help documentation.
Custom Attributes enables to:
- Define a single data source template
- Keep common values shared across all customers
- Dynamically inject customer‑specific values (such as database name) at runtime during embedding
This functionality is specifically designed for multi‑database SaaS architectures like Bold Corp’s setup.
Step‑by‑Step Guide: Unified Sales Analysis Dashboard Preparation
This section explains how Bold Corp can build one unified Sales Analysis dashboard, publish it once, and embed it so that each customer sees data from their own schema, using Custom Attributes in Bold BI.
Step 1: Create the Custom Attribute with a Default Value
Create a custom attribute to dynamically pass the schema name, since schema values vary per customer. In the provided example, we are creating a custom attribute to dynamically pass schema values, as these values vary for each customer:
In this example, we assume the creation of a custom attribute named sales_analysis_schema with a default value of alpha_electronics. The subsequent steps will demonstrate how this attribute can be modified during embedding to support dynamic value passing.
Step 2: Create the Data Source Using the Custom Attribute
- In the Bold BI dashboard designer, create a new data source.
- Configure the Database name as
sales_analysis_dbin the data source connection properties section. - Drag and drop the
sales_analysis_datatable from thealpha_electronicsschema into the data source design canvas area. - Switch the design mode to
code viewmode in the data source page
- In the code view mode query, replace the schema name using the custom attribute
sales_analysis_schema - This allows the same data source definition to dynamically query different schemas at runtime.
Step 3: Create and Publish the Sales Analysis Dashboard
Design the Sales Analysis dashboard using the data source created in the previous step and publish it to Bold BI.
Design your dashboard using the data source created in the previous step and publish it to Bold BI. Since the data source is dynamic, the same dashboard can be reused across multiple tenants.
Important: Creating separate dashboards for each customer is unnecessary. By default, the dashboard uses the database schema value configured for the custom attribute. During embedding, values will be dynamically passed based on the user—a process that will be explained in the upcoming steps.
Step by Step Guide: Embedding the Dashboard into the Application
Step 1: Generate the Embed Token with Custom Attribute Values
To embed a Bold BI dashboard securely in your application, you must generate an Embed Token. From Bold BI v14.1, we introduced an object model structure to generate a token by calling the token generation endpoint via a POST API call, which makes it easier to provide the necessary details.
Important:The Embed Secret Key is required to securely embed Bold BI resources within external applications. This key can be generated from the Bold BI Server by an administrator.
For step-by-step instructions, security considerations, and configuration details, refer to the official Bold BI documentation: Bold BI User Guide – Embed Settings
When a user logs into the Bold Corp embedded sample application:
- Identify the customer associated with the user in your embedding application logic.
- Determine the corresponding database schema name:
- Alpha Electronics →
alpha_electronics - Beta Enterprise →
beta_enterprise - Gamma Industries →
gamma_industries - Delta Industries →
delta_industries
- Alpha Electronics →
- Generate the embed token for the dashboard.
- While generating the token, pass the custom attribute value:
DatabaseName = <customer database name>
[HttpPost]
[Route("TokenGeneration")]
public string TokenGeneration()
{
// Get logged-in user email from your application authentication context
string userEmail = UserContext.GetEmail();
// Resolve tenant associated with the logged-in user
string userTenant = UserContext.GetTenant(userEmail);
// Resolve database name based on tenant
// (Hard-coded for sample understanding; replace with DB/config lookup in production)
string userDatabaseSchemaName;
if (userTenant == "Alpha Electronics")
userDatabaseSchemaName= "alpha_electronics";
else if (userTenant == "Beta Enterprise")
userDatabaseSchemaName= "beta_enterprise";
else if (userTenant == "Gamma Industries")
userDatabaseSchemaName= "gamma_industries";
else if (userTenant == "Delta Industries")
userDatabaseSchemaName= "delta_industries";
var embedDetails = new
{
serverurl = "http://localhost:52206/bi/",
siteidentifier = "site/site1",
email = "[email protected]",
embedsecret = "<Embed Secret Key>",
customattributes = new List<object>
{
new {
name = "sales_analysis_schema", // Name of the custom attribute
value = userDatabaseSchemaName, // Value for the custom attribute assigned from your business logic
@operator = "" // optional
}
}
};
//Post call to Bold BI server
var client = new HttpClient();
var requestUrl = $"{embedDetails.serverurl}/api/{embedDetails.siteidentifier}/embed/authorize";
var jsonPayload = JsonConvert.SerializeObject(embedDetails);
var httpContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
var result = client.PostAsync(requestUrl, httpContent).Result;
var resultContent = result.Content.ReadAsStringAsync().Result;
return JsonConvert.DeserializeObject<dynamic>(resultContent).Data.access_token;
}
This step dynamically binds the dashboard to the correct database.
Step 2: Embed the Dashboard in the Front End Application
- Once an embed authorization token has been generated on the backend server side, use it on the frontend to securely render a Bold BI dashboard.
- Add a container with a unique ID where the dashboard will be rendered.
- Use the embed SDK to create a Bold BI instance with your server details, dashboard ID, and the embed token retrieved from your backend.
Note: To identify the Dashboard ID in Bold BI, refer to the following knowledge base article, which explains the available methods in detail:
How to Get the Dashboard ID in Bold BI
<div id="dashboard_container_id"></div>
<script>
var boldbiEmbedInstance = BoldBI.create({
serverUrl: "http://localhost:52206/bi/",
dashboardId: "<Dashboard Id>",
embedContainerId: "dashboard_container_id", // Div ID where dashboard will render
embedToken: "<Embed token generated from backend server>" //Discussed in Previous section
});
boldbiEmbedInstance.loadDashboard();
</script>
- Load the Sales Analysis dashboard using the Bold BI embedding SDK.
- Bold BI reads the custom attribute value from the token.
- The dashboard connects to the specified customer database and renders the data.
Resulting Behavior
- Bold Corp maintains one Sales Analysis dashboard
- All customers share the same database (
sales_analysis_db) - Each customer accesses only their own schema
- Schema resolution happens at runtime
- No dashboard duplication or manual configuration is required
Benefits for Organizations
By using Custom Attributes with a schema‑based multi‑tenant architecture, organizations achieve:
- One unified dashboard design
- Logical tenant isolation at the schema level
- Simplified dashboard maintenance
- Effortless onboarding of new customers (only a new schema is required)
Benefits for Orgnizations
By using Custom Attributes in Bold BI, the orgnizations like Bold Corp achieves:
- One unified Sales Analysis dashboard
- No dashboard or data duplication
- Clean separation between dashboard design and customer context
- Native alignment with database‑level multi‑tenant architecture
- Effortless onboarding of new customers (only a new database is required)
Summary
In the Bold Corp SaaS example embedded application, Custom Attributes act as the bridge between:
- A shared dashboard design, and
- customer‑specific database schemas
This allows Organizations to embed a single Sales Analysis dashboard and dynamically serve the correct data to every customer, making the analytics layer as scalable and secure as the underlying SaaS architecture.
Additional References
Getting Started with Bold BI
- User Guide Documentation: Bold BI Evaluation Quick Start
- User Guide Documentation: Creating Dashboards
- User Guide Documentation: Working with Data sources
Bold BI Embedding Concepts