NoSQL Data Models

Reading

Reading questions

Notes

Aggregate Data Models

An aggregate is a collection of related objects that we treat as a unit. These aggregates tend to transcend the normalized breakdown that relational databases promote. For example, recall our basic evaluations database structure:

Evaluations Database Relationships

Evaluations Database Relationships

There are many different "aggregates" we could consider. Ultimately what determines an aggregate has to do with the kinds of queries one might want to perform.

The idea is that aggregates tend to put together all the information that will tend to be processed together. This simplifies and speeds up those queries that respect this unit of interaction.

On the other hand, it also makes other queries more complicated. Suppose for example that we wanted to get summary information about all student answers to a particular question. With our aggregate example above, we have essentially two approaches:

So bottom line: In aggregate data models, some queries that respect the aggregate structure are fast, while other queries that transcend the structure become harder to perform.

Key-Value Stores and Document Databases as Aggregate Data Models

Both key-value stores and document databases emphasize an aggregate-oriented design: Each aggregate is identified by its id/key and treated as a unit.

The difference between the two is on how the contents of the aggregate are treated: