Share a single database across multiple clients (a multitenancy) in a Spring Boot app

Hi all!

I’m going to build a Spring Boot application for Jira Cloud and just stumbled across a question about storing clients data in a database.
As far as I understood the concept correctly all the clients’ data is stored in one single database, is that correct?
If the answer is yes my question is which is the best way to determine if data belongs or not to a certain client?

Do I have to add a new column to each entity with a client key(e.g. AtlassianHost.getClientKey()) to make sure that the data belong to that client? Is it enough? Do I need to take other actions to make sure that the data is secured and not accessible by other add-ons users (customers)?
If yes, which is the best way to get the client’s key? Use com.atlassian.connect.spring.AtlassianHost.getClientKey() method?

Thank you in advance. Any advice and suggestions will be greatly appreciated.

Thanks,
Artem

Hi @artemg,

Do I have to add a new column to each entity with a client key(e.g. AtlassianHost.getClientKey()) to make sure that the data belong to that client? Use com.atlassian.connect.spring.AtlassianHost.getClientKey() method?

Yes and yes.

Another approach is to have tenant separation in your database. A Guide to Multitenancy in Hibernate 5 is a starting point.

1 Like

Great, thank you, @epehrson, for the prompt response!

Just wondering if it’s possible to use Multitenancy with Spring Data but it’s another question that has nothing to do with Atlassian Development. :wink:

Thanks,
Artem