this contains entities such as customers, bookings, services, etc etc. All these entities are related to each other @ the database level.
It is actually how a monolith system looks like.
What I am wondering is, should each of these entities (bookings, customers, services, etc) be their own API and microservice?
The only ones capable to answer to this question is probably you, product owner and different stakeholders. So those who knows the business, their entities and their relation between them.
Don't forget that the goal is not the microservices design.. it just the strategy.
Focus on outcomes and depending on them maybe you'll see that the monolith approach is better.
You should be thinking of going to a microservice architecture in order to achieve something that you can’t currently achieve with a monolith one.
Regarding relationship, if you go to a microservices approach customers and booking tables will end up living in different schemas, so what happens with our foreign-key relationship? We have two key problems to consider. First, how correlate entities if it can no longer do this via a database join? The other problem is, what do we do about the fact that data inconsistency could now exist..
Your database joins will be replace by service calls (API call).
Now you should take care of latencies. It will be probably slower than db calls but slower can be acceptable if it fast enough for you. Using a tracing system like jagger or zipkin will provide help to measure latencies between your services.
Regarding consistency the true challenge is the split of your business transaction. When you could handle all your relations inside a single local transaction now you have to handle multiple local transactions and more important
Take a look at
SAGA pattern. You can see that as
chaining local transactions and create compensating transaction to handle rollback.
When you start considering effectively breaking foreign-key relationships, one of the first things you need to ensure is that you aren’t breaking apart two things that really want to be one. You should look about the concept of