Designing the database for multi-tenancy
Our database needs to be set up for multi-tenancy. But to do that, it’s crucial to have a clear view of what our target vision is and what our data must look like. You know the project and you know that there are going to be tenants and users. But what does that mean database-wise?
Planning our database
Here are the semantical, architectural questions that will help us plan our database:
- What is a tenant within the application?
- What is a user in the context of our application?
- What information must the database contain for us to know if a user has access to a tenant or not?
Let’s go ahead and answer these questions.
Defining the tenant
A tenant, at the absolute minimum, is defined by its actual real name – for example, Packt Publishing – and a technical but human-readable, unique identifier – for example, packt, packt-books, or super_cool_books (a typical alphanumerical string...