I would like to build a microservices architecture to handle the following scenario: I have a building. The building has some kinds of devices. And the devices can be used by the users. In the system, the administrator can add a user and allow the user to use selected devices in the building.
I have user service, device service, building service, authentication service. Each service has own database. The problem is where to store relations between users and buildings, buildings and devices?
To indicate which user has access to the device I need to store relation: device_id - user_id but it should be in the table devices_users in the user service or in device service? The same for the relation building_id - user_id and device_id - building_id. Could anyone help my with this issue? Maybe I have designed the microservices in wrong way?