Skip to content
IT glossary
ArchitectureUpdated December 3, 2026

CQRS

This architectural pattern uses separate models for changing data and reading it. The write model enforces business rules, while the read model returns data in the form a screen, report, or other client needs.

What CQRS separates

CQRS stands for Command Query Responsibility Segregation. A command asks the system to do something, such as reserving a seat. A query asks for information, such as which seats are available, without changing business state. Most applications already have operations of both kinds. What makes a design CQRS is that it uses different models for those operations, not merely different endpoints or method names.

One database is enough

The write model is designed around decisions: Is the request allowed? Which rules must hold when the change is committed? The read model is designed around answers: Which fields does this screen need, and how can it fetch them efficiently? Both models can live in the same application and use the same tables. A command handler can write within a transaction, while a query handler uses SQL to return a result shaped for a particular screen.

If those queries are expensive, the read side can instead use a precomputed view of the data, often called a projection. Updating that projection in the background takes work off the command path, but creates a window in which a successful write is not yet visible to readers. That lag comes from asynchronous updates, not from CQRS itself.

Example: booking a seat

ReserveSeat(showId, seatId) must prevent two customers from reserving the same seat. Its handler checks availability and protects the reservation against concurrent writes, for example with a database uniqueness constraint. GetSeatMap(showId) returns seat labels, prices, and availability in a shape the booking page can render. If the seat map is an asynchronous projection, it can briefly show a reserved seat as available. The command handler must still reject a second reservation: the seat map is useful for display, but it is not the authority on whether a booking can be made.

When the split pays off

CQRS is worth considering when writes enforce substantial business rules and reads need a very different shape, or when read traffic needs to scale independently. A separate read store can help in the latter case, but someone has to monitor projection lag and handle retries without applying the same update twice. For straightforward CRUD, a shared model is usually easier to build and maintain.

What interviewers look for

Start with the simplest design that meets the requirements. If you propose an asynchronous read model, explain what users will see immediately after a successful write and how much lag they can tolerate. Keep CQRS distinct from Event Sourcing: Event Sourcing makes a sequence of events the source of truth, while CQRS separates the models that handle reads and writes. Neither pattern requires the other.