Design API data model for communicating with the service, object model for the application logic, and storage model for persisting the data.
A data model organizes data elements and formalizes their relationships with one another. In database design, data modeling is the process of analyzing application requirements and designing conceptual, logical, and physical data models for storage. However, data storage is only one, albeit an important, aspect of microservices.
There are three related but distinct data models in a microservice for:
- API Data Model for interactions: It defines the schema of data payload that can be sent to or is received from the endpoints of a microservice. Also known as communication or exchange data model.
- Object Data Model for computations: It is designed for efficient business logic implementation. Also known as application data model or data structures.
- Storage Data Model for persistence: It defines the schema of various, occasionally redundant, data stores and caches.