Database Reference
In-Depth Information
Chapter 9. Aggregating Time-Series Data
In the preceding chapters, you learned how to use Cassandra as a primary data store for the
MyStatus application, with a focus on modeling the data that drives the main user experien-
ce on the site. In this chapter, we'll shift focus to another popular use of Cassandra: aggreg-
ating data that we observe over time. In particular, we'll build a small analytics component
into our schema, allowing us to keep track of how many times a given status update was
viewed on a given day.
In order to do this, we'll introduce a new type of column, the counter column, which is a
special numeric column type that can be discretely incremented or decremented. Counter
columns have a lot in common with collection columns, which we explored in the previous
chapter: you can make discrete changes to them without reading their current value, and
they're good for scenarios in which many threads or processes might need to update the
same piece of data at the same time.
There are also big differences between counter columns and collection columns: most obvi-
ously, counter columns only hold a single scalar value, whereas collection columns hold
multiple values. There are also more subtle differences and limitations that we'll explore in
this chapter.
By the time you're done with this chapter, you'll have learned:
• How to construct tables for time-series aggregation
• How to define a counter column
• How to increment and decrement a counter column
• Limitations of counter columns
Search WWH ::




Custom Search