Aram Mkrtchyan
Aram Mkrtchyan

Reputation: 455

Microservices Per DB table

I ran into the microservices architecture for e-commerce application where each table has it's own micro service basically with CRUD operations (something like rest client for each table). Now I am thinking about combine and model them around business domains, before that I wanted to know does anyone encountered such situation and is it right architecture or not. Any suggestions will be very helpful. Thanks.

Upvotes: 1

Views: 2824

Answers (3)

Jim Ferrans
Jim Ferrans

Reputation: 31012

Each microservice should have its own set of SQL tables that no other microservice can access. But having one microservice per SQL table, and having each microservice just support CRUD operations is generally an anti-pattern: it turns a powerful DBMS and query language into a simple record manager: no cross-table transactions, joins, filtering, sorting, pagination, etc.

Upvotes: 7

techagrammer
techagrammer

Reputation: 1306

Microservices are logical block for any application , combining them at sql level dosen't make any sense.

For eg: let's consider you create an order service , which allow customer to place order.

Now a order contain order items as well and may have a reference of customer object , for all these you might end up creating multiple tables. So don't just think sql table and microservices together

If you still have doubts post a more exact question , will help :)

Upvotes: 3

FuzzyAmi
FuzzyAmi

Reputation: 8119

You're mixing up different, unrelated things.

(micro)services are logical entities that do some specific task. they communicate with other services to perform a larger-scope task.

Tables/CRUD/SQL/NO-SQL come from an entirety different level. its where data is saved and how its accessed.

Its true that services use SQL and have tables. Its also probably a good idea to have separate tables for each service. I would even go as far as saying that if 2 services directly use the same table you're probably looking at a design problem.

but you can't equate services with tables, conceptually, they belong in different worlds.

Upvotes: 4

Related Questions