Hi Kelvin,
First of all, you can create a multi-tenant structure by defining a separate data source for each tenant (service provider) and without making any changes to the data model. You will need to determine the data source definition according to the technology you are using.
To give a more concrete example: Let's say you are using Java and hibernate. To develop a multi-tenant system, you can define data sources as you can see at
https://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch16.html.You can define your own data sources per tenant (SP) similar to given examples in the link.
However, if you want to set up a multi-tenant structure based on "single database-single schema" with a tenant id (service provider) without defining separate data sources; You can use the related_party field as the tenant_id (service provider). Almost all main entities have related_party field. Because service provider is also a related party.
Add SP info to related party list of entities on creation. Filter on read operation etc.
While securing APIs with OAuth2, you can carry tenant (service provider) information in JWT claims. It will be safer to obtain SP info from user privileges than sending this information from header or query parameters.
You can use the the related party (service provider information) as the desired tenant identifier in the 3rd "Partitioned (discriminator) data)" option in the Hibernate example. In this 3rd option, I think it would be appropriate to add tenant_id (service_provider_id) to the data model to get more performance queries.
When you do not use different data sources, tenant control is required in all CRUD operations. For example, in the read operation, tenant information (from privileges of the user logged into the API) should be added to the filters automatically.
------------------------------
Mustafa Yusufoglu
i2i Systems
------------------------------
Original Message:
Sent: Jun 12, 2021 21:45
From: Kelvin Chua
Subject: multi-tenancy
hi,
anyone has idea on how the openapis handle multitenancy?
i.e. TM700/shippingOrder/{id}
------------------------------
Kelvin
------------------------------