When we explore precomputed aggregate data storage, let's focus on the first question posed earlier: how many total views did status updates receive on each day of September?
More generally, we want to store the daily overall view counts in a structure that allows us to easily retrieve the counts for a given range of time. We don't need to store discrete information about every view event that happened; simply knowing how many views occurred per day is sufficient.
Let's create a new daily_status_update_views table that aggregates our analytics observations at just the right granularity:
CREATE TABLE "daily_status_update_views" (
"year" int,
"date" timestamp,
"total_views" counter,
"web_views" counter,
"mobile_views" counter,
"api_views" counter,
PRIMARY KEY (("year"...