Cross aggregate validation

I’m working to replace my CRUD booking system with a new one based on CQRS + ES.

Resource is an aggregate (represents a physical thing you can book).

One booking can represent many resources bookings during different periods.

Say I have





and I create a booking like

HouseA: From: 2014-10-01, To: 2014-10-05

HouseB: From: 2014-11-01, To: 2014-11-05

HouseC: From: 2014-12-01, To: 2014-12-05

(Attaching an image from a CRUD based system to make it easier to understand)

Needles to say I want avoid double booking.

How would you handle this with event sourcing? I’ve been trying different approaches - nothing seems to be right.


This is set based validation. I’m struggling with w very similar problem…

I’m swaying towards hydrating the AR with enough of the data as value objects to allow it to validate the set - these value objects are immutable so I don’t see an issue.

First question does the house actually hold the information or is it
really all contained in one aggregate say "schedule" with references
out to the resources in question. Is their cross schedule validation?

in my current system Resource (House) doesn’t know it is booked or not. House knows it’s name, it’s facilities, it’s state (needs cleaning for example).
Weather it is free or not is always calculated based on all the bookings made for that resource.

At present, scheduling serivce does some sql queries over bookings table since that’s where all the information is.

In CQRS/ES - i cannot simply do such a query - save for read side.

Not sure if that clarifies my issue.