Database Reference
In-Depth Information
• Categories have three components in its primary key. One is the category name,
which is the partition key, another is the blog ID, and then the post ID. One can
argue that inclusion of the post ID in the primary key was unnecessary. You could
just use the category name and blog ID. The reason to include the post ID in the
primary key was to enable sorting by the post ID.
• Note that some of the IDs in the table definition are timeuuid . The timeuuid
data type is an interesting ID generation mechanism. It generates a timestamp-
based (provided by you) uuid , which is unique and you can use it in applications
where you want things to be ordered by chronology.
Inserting records
This section demonstrates inserting the records in the schema. Unlike RDBMS, you will
find that there are some redundancies in the system. You may notice that you cannot have
a lot of rules enforced by Cassandra. It is up to the developer to make sure the records are
inserted, updated, and deleted from appropriate places.
Note
Note that the CQL code is just for instruction purposes and is just a snippet. Your output
may vary.
We will see a simple INSERT example now:
cqlsh:weblog> INSERT INTO blogs (id, blog_name, author,
email, password) VALUES (
blobAsUuid(timeuuidAsBlob(now())), 'Random Ramblings', 'JRR
Rowling', 'rowling@yahoo.com', 'someHashed#passwrd');
cqlsh:weblog> SELECT * FROM blogs;
id | author | blog_name |
email | password
------------+-------------+------------------+-------------------+--------------------
83cec... | JRR Rowling | Random Ramblings |
Search WWH ::




Custom Search