Command Query Responsibility Segregation (CQRS) is a proven design pattern that enables the clear separation of data changes (commands) and data queries (queries). This separation allows each of these responsibilities to be scaled and optimized independently. An essential question in the application of CQRS is whether two separate data stores are necessarily required or whether CQRS can also be used effectively to keep data in a single database while still structuring the application code more efficiently and optimizing the data access.
In this talk, we will deepen the understanding of the practical implementation of the CQRS principles. We use jOOQ, a type-safe SQL query library, as our persistence layer and model both the query and command models using Java Records. Using a concrete example application, we demonstrate how the theoretical foundations of CQRS can be applied in practice and how this affects the design of applications and improves the data access performance.