Structure of a CQRS event store

Look at http://geteventstore.com/ - this version by Greg Young is also has source available for your perusal [with a BSD 3-clause license on GitHub].


Aggregates have to do with cqrs but not directly with an event-store. You're right there are two collections but these are events and snapshots. For more details look at: https://github.com/jamuhl/nodeEventStore


I would suggest you to have a look at Jonathan Oliver's EventStore for reference.

In the SQL persistence version there's only one table. You could easily live without the aggregate table and store the aggregateId in the events table. The latest version could be retrieved by using a max() query.

Other than that I think you should consider having headers in the events table, cause there are always interesting metadata that you don't want to store in the events themselves.

And also, I think you should add a date column in the events table.

Finally, you probably want to have some sort of flag that states if the event has been dispatched downstream or not. This addition enable you to write in one thread or process and dispatch in another.

Aaand there, I have sort of suggested the structure of Jonathans EventStore.


I can't add much to Mikael's answer.

Here's just one more thing as a reference: A few years ago Greg Young wrote down his thoughts about an event store implementation. The document can be found at http://cqrs.wordpress.com/documents/building-event-storage/

Although I believe his approach has evolved in the meantime as well.