Partitioning And Storage Structure

DSE Version: 6.0

Video

Exercises

We will be talking about partitioning and storage structure in this unit, both very important topics for Apache Cassandra data modeling.

NO TRANSCRIPT AVAILABLE.

No write up.

Exercise 2.1: Working with Partitions

In this exercise, you will:

  • Create a new table that allows querying videos by title and year using a composite partition key

Background

Your peers need to query videos based on 'title' and 'added_year'. The new columns for this table are:

Column NameData Type
titletext
added_yearint
added_datetimestamp
descriptiontext
user_iduuid
video_iduuid

Steps

1. Use a text editor to view the '/home/ubuntu/labwork/partitions/videos_by_title_year.csv' file.

2. At prompt, navigate to '/home/ubuntu/labwork/partitions/'.

3. Start 'cqlsh'

4. Create a second table in the 'killrvideo' keyspace called 'videos_by_title_year'with the structure shown in above table. Be sure users can query this table on both 'title' and 'added_year'by combining them into the partition key.

5. Load the data from the 'videos_by_title_year.csv'file using the `COPY` command.

6. COPY videos_by_title_year (title, added_year, added_date, description, user_id, video_id) FROM 'videos_by_title_year.csv' WITH HEADER=true;

7. Try running queries on the 'videos_by_title_year' table to query on a specific 'title' and 'added_year'.

Example queries:

titleadded_year
Introduction to Apache Cassandra2014
Grumpy Cat: Slow Motion2015
Grumpy Cat: Slow Motion2015
AzureDev2015

8. What error does Cassandra return when you try to query on just title or just year? Why?

9. Exit cqlsh.

No FAQs.
No resources.
Comments are closed.