SaaS Application Database design approaches
One of the concern areas for any clients (tenants) in using any SaaS model application is “Data privacy”. “Data Sharing” option would really help the tenants, provided the application database design approach is fool-proof and build the confidence amongst the tenants.
SaaS (Software as a Service) is a model of software development whereby a provider licenses an application to customers (subscribers or tenants) for use as a service on demand. SaaS based applications are multi-tenancy not multi-instance application architecture.
“Data Storage”, “Data Synchronization” and “Database Maintenance” are three key focus areas from the deployment perspective. I came up with the following 3 database design approaches and optimized them to make the best out of each.
1. Individual databases servers:
The best way to isolate the tenant’s data is to deploy the tenant data in separate database server. This approach is it is easy to extend the existing database to meet tenant’s customization requirements. Flip side of this approach is its high cost of hardware inventory, licensing cost per hardware, and maintenance. Few tenants’ who requires a high degree of data isolation (physical) and are willing to pay more can opt for this design approach.


2. Shared database servers with Individual Schemas:
Tenant specific schemas would be created in the same database server and access rights permissions are enabled in such a way that a tenant can access only the resources (tables, stored procedures etc) in their specific schema. The key advantage of this approach is lower cost and support a virtually unlimited number of tenant’s databases. This approach will improve the performance of the application as we can work around a solution to effectively utilize the connection pooling. Even though the tenant’s databases are in different schemas in the same server, we can use the following technique to maximize the performance in DB connection. The following code is in C# (Microsoft .Net platform) and I am sure we can do the same with other languages as well.
1) objConnection.ConnectionString ="Data Source=MSSQL1;
InitialCatalog=FunnelDatabase; Integrated Security=true;";
2) objConnection.Open();
3) objConnection.ChangeDatabase(”Tenant1″);
4) objCommnad.execute ("storedprocedurename");
The point # 3 in the above code is important. An initial connection to the database server has been established to FunnelDatabase. However, before executing the stored procedure / SQL statement, line #3 is changing the target database to Tenant1. By doing so, we are still utilizing the initial connection string and hence using the same connection pool for all the target databases.

3. Same Database with Same Schema:
All tenants’ data resides in same schema and share the same set of tables. But, a tenant identifier can be added to the primary key (composite key). A key challenge in this approach is it is not customizable at tenant level and rigorous testing required to gain the tenant’s confidence for data security and data privacy. Barring the above concerns, this is the best among all three approaches in terms of cost and maintenance. Even in this approach, we can establish some degree of data isolation by using some of the advanced techniques such as “Partitioning methods“, which allow physical data separation of each tenant’s data across physical devices while providing simplification of maintenance due to shared table definitions.
Let us talk about deployment strategies with networking options in our next blog.



























Recent Comments