Database Reference
In-Depth Information
(2 rows)
cqlsh:weblog> INSERT INTO categories (cat_name, blog_id,
post_id, post_title) VALUES ( 'random',
83cec740-22b1-11e4-a4f0-7f1a8b30f852,
c06a42f0-22b2-11e4-a4f0-7f1a8b30f852, 'Fooled by
randomness...');
cqlsh:weblog> INSERT INTO categories (cat_name, blog_id,
post_id, post_title) VALUES ( 'maths',
83cec740-22b1-11e4-a4f0-7f1a8b30f852,
c06a42f0-22b2-11e4-a4f0-7f1a8b30f852, 'Fooled by
randomness...');
Note
You may want to insert more rows so that we can experiment with pagination in the up-
coming sections.
You may notice that the primary key, which is of type timeuuid , is created using Cas-
sandra's built-in now() function, and we repeated the title in the categories table.
The rationale behind repetition is that we may want to display the title of all the posts that
match a tag that a user clicked. These titles will have URLs to redirect us to the posts (a
post can be retrieved by the blog ID and post ID). Alternatively, Cassandra does not sup-
port a relational connect between two tables, so you cannot join categories and posts to
display the title. The other option is to use the blog ID and post ID to retrieve the post's
title. However, that's more work, and somewhat inefficient.
Let's insert some comments and upvote and downvote some posts and comments:
# Insert some comments
cqlsh:weblog> INSERT INTO comments (id, post_id,
commenter, title, content, posted_on) VALUES (now(),
c06a42f0-22b2-11e4-a4f0-7f1a8b30f852, 'liz@gmail.com',
'Thoughful article but...', 'It is too short to describe
the complexity.', 1407868973000);
Search WWH ::




Custom Search