Use the Northwind Sample Database for a Multi-Tenant Application


The Northwind Traders sample database contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. The Northwind database is a sample that ships with most Microsoft technologies (SQL Server, Access, etc.)

In order to adhere to best coding practices and adapt the Northwind Database to the Apprenda Platform data deployment model, a few changes needed to be made. The following is a list of the changes:

  • Move the provisioning of the data to its own script called TenantProvisioning_Script. This allows every tenant when onboarded to have its own copy of the records.
  • The insertion commands rely on turning on identity insert for every table so keys can be hard coded in. This does not adhere to best practices so I modified the inserts to not explicitly have the key for each row.
  • The sample data scripts also rely on turning off foreign key relationships in order to allow for a disorganized insertion of the data. I reorganized the scripts to insert the data in order and honor the relationships set up for the tables.

It is also important to note that Apprenda allows you to deploy your multi-tenant application in a commingled DB approach or an isolated one. Because the Northwind data scripts rely on hard coded ids for almost every row, they will only work with an isolated model. I did not modify the scripts to remove this limitation, but it is possible to do so by removing the hardcoded ids from the TenantProvisioning_Script.

I am attaching the two working scripts ApplicationProvisioning_Script and TenantProvisioning_Script for reference. These scripts are ready to be added to an Apprenda Archive and deployed on the platform.

Have more questions? Submit a request