DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

aslums avatar image
aslums asked Erick Ramirez answered

Questions about DS220 Data Modeling course exercise 5.5 "Table Optimizations"

Hi,

I am learning the Data Modeling course DS 220. There are 3 questions,

Qn 1. Splitting partition for the video table. Can I use user id, as a compound partition key?

Qn 2: videos_by_user. Is the answer to use title, along as partition key?

Qn3: Can we split the table, like user id, video id, comment and user id, video id, thumbnail? Does that work.

Please let me know if my assumptions/answer is wrong? with some explanation

academydata modelingds220
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Here are my responses to your questions.

Qn 1. Splitting partition for the video table. Can I use user id, as a compound partition key?

It doesn't make sense to use the user_id as a clustering column since each video will only ever have a single user. There will only ever be 1 row in the partition so there is no reason to split it.

As a side note, I think you meant composite partition key. I've explained the various terminologies in question #6171.

Qn 2: videos_by_user. Is the answer to use title, along as partition key?

The PRIMARY KEY right now is:

CREATE TABLE videos_by_user (
  ...
  PRIMARY KEY (user_id, video_id)
)

This table supports the query "Find videos uploaded by a user". Changing the PRIMARY KEY to use the title instead doesn't really change the table in a meaningful way.

Also, the video titles may not necessarily be unique since users can name their videos whatever they want. For this reason, we are using video_id.

One way (there could be several) to split the partition is to add a date range. For example, split partitions based on the year a user uploaded videos:

CREATE TABLE videos_by_user (
  user_id uuid,
  year int,
  video_id timeuuid,
  ...
  PRIMARY KEY ((user_id,year), video_id)
)

Qn3: Can we split the table, like user id, video id, comment and user id, video id, thumbnail? Does that work.

Yes, you can. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.