Aggregate Oriented Database
Aggregate Oriented Database
19 January 2012
Martin Fowler
DATABASE
NOSQL
One of the first topics to spring to mind as we worked on Nosql Distilled was that
NoSQL databases use different data models than the relational model. Most sources
I've looked at mention at least four groups of data model: key-value, document,
column-family, and graph. Looking at this list, there's a big similarity between the
first three - all have a fundamental unit of storage which is a rich structure of
closely related data: for key-value stores it's the value, for document stores it's the
document, and for column-family stores it's the column family. In DDD terms, this
The rise of NoSQL databases has been driven primarily by the desire to store data
effectively on large clusters - such as the setups used by Google and Amazon.
Relational databases were not designed with clusters in mind, which is why people
have cast around for an alternative. Storing aggregates as fundamental units makes
a lot of sense for running on a cluster. Aggregates make natural units for
distribution strategies such as sharding, since you have a large clump of data that
This synergy between the programming model and the distribution model is very
valuable. It allows the database to use its knowledge of how the application
There is a significant downside - the whole approach works really well when data
access is aligned with the aggregates, but what if you want to look at the data in a
different way? Order entry naturally stores orders as aggregates, but analyzing
product sales cuts across the aggregate structure. The advantage of not using an
aggregate structure in the database is that it allows you to slice and dice your data
can reorganize the data into different groups for different readers - what many
people refer to as materialized views. But it's more work to do this than using the
relational model.
databases when you are manipulating clear aggregates (especially if you are
running on a cluster) and use relational databases (or a graph database) when you