Most people say when building micro-services
, that it's best to have separate databases for each of the microservices.
E.g:
User-microservice:
- DB - User
- userId
- name
- Etc...
Review-microservice:
- DB - Review
- userId | The user who posted the review
- Review-description
But I've been thinking, is it best to have a ORM
which builds the database tables, adds the foreign keys, primary keys, indexes, etc...And then have each of the micro-services use the database which was built by the ORM
.
This would enforce constraints, which would hopefully prevent the number of bugs/issues you come across later on, It'd also help with query performance (joins, indexes, etc...).
Here's what I'm thinking:
We currently have a monolithic API which contains a lot of code (years of it) and a complex DB schema design, I'm thinking of building micro-services in Java
and using hibernate
to create models based on the django
schema.
Is this a good approach?