All Articles

Pattern: Database View

Sam Newman (2019), Monolith to Microservices, O′Reilly.

Pattern: Database View

In a situation where we want a single source of data for multiple services, a view can be use to mitigatethe concerns regarding coupling. With a view, a service can be presented with a schema that is limited projection from an underlying schema. This projection can limit the data that is visible to the service, hiding informaton it should have access to.

Database view

The ability of a view to project only limited information from the underlying source allows us to implement a form of information hiding. It gives us control over what is shared, and what is hidden.

Typically views are the result of a query. This means that the view itself is read-only. This limis their usefulness. Another limitation is the need for both the source schema and view to be in the same database engine.