Database Reference
In-Depth Information
Recording discrete analytics observations
Let's say we want to keep very close track of how many times our users' status updates are
viewed by someone else. Status updates may be viewed on the MyStatus web site, or by us-
ing our mobile app, or via a third-party app using our API. We'll want to track that, as well
as which status update was viewed and when. To do this, let's create a table to store analyt-
ics observations:
CREATE TABLE "status_update_views" (
"status_update_username" text,
"status_update_id" timeuuid,
"observed_at" timeuuid,
"client_type" text,
PRIMARY KEY (
("status_update_username", "status_update_id"),
"observed_at"
)
);
In this new table, we store a partition for each individual status update, with the full
primary key of the status update serving as the partition key for our table. Each time
someone views a status update, we'll store a new row in the table, generating a timestamp
UUID for the row to populate the observed_at clustering column.
We'll also, for each observation, keep track of what type of client was used to view the
status update: the web site, our mobile app, or a third-party API client. We could, of course,
keep track of many other bits of metadata about the observation, such as the IP address of
the user, the exact browser or app version being used, and so on.
Search WWH ::




Custom Search