Database Reference
In-Depth Information
Here are some advanced questions that we want you to ponder on; also, you can
share your answers on the topic's site:
• Can you determine how many people never finish watching a particular
video?
• With this, here's an analytics question. What is the problem with that video?
What videos are never watched to completion? Why?
These are really advanced, real-life questions. Try to find a solution for the problems
we just mentioned. The hint here is to create yet another table for the last five videos
that you watched, as follows:
CREATE TABLE video_playlist (
username varchar.
play_ts timestamp;
videoid uuid
PRIMARY KEY (username,play_ts)
) WITH CLUSTERING ORDER BY (play_ts DESC);
This is another table to maintain, but this will provide you with an answer in a
reasonable time.
Dealing with transactions
How do you implement transactions? What a question! You might say, "My SQL
database provides them for me!" Indeed, in your code, you start a transaction, lock
the database row or two rows, and either complete the transaction or roll it back.
However, it is not as easy as it sounds. Even in the world of SQL, this leads to
two-phase commits, and they in turn lead to locks to the database; hence, the
application remains unavailable for a period of time. However, if you are a bank,
you really have no choice. People won't like it if their money goes out of their
account (the transaction starts) occasionally and then due to a malfunctioning
of the system that does not have transactions, this money does not end up either
with their friend they've been sending the money to or in their other account.
A bank must have transactions. However, most of us don't have this.
 
Search WWH ::




Custom Search