PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

mandardotkulkarni_162904 avatar image
mandardotkulkarni_162904 asked ·

is Clustering column mandatory

Hello,

Need to understand below

1. create table d(a int,b int,c int, primary key((a,b)));

Here Primary key = composite partition key with no clustering column.

2.create table e(a int,b int,c int, primary key(a,b));

Here Primary key = compound primary key where partition key=a and clustering key=b

Please let me know if above understanding is correct ?

cassandra
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.

davebechberger avatar image
davebechberger answered ·

Your understanding is correct, a clustering key is not required.

In the first example, you will create a table with a composite partition key of a and b which means that your data will be partitioned by both those values. When running CQL queries on this table it includes both a and b as filtering columns in the WHERE clause.

In the second example, you will create a table with a compound primary key where the partition key is a and a clustering column is b. This means that your data will be partitioned by a and then sorted by b, in descending order. When running CQL queries on this table it must include a as a filtering column in the WHERE clause and filtering on b is optional.

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.

sainikhilguntur_181814 avatar image
sainikhilguntur_181814 answered ·

Basically clustering columns are used by cassandra to arrange the data in clusters by sorting on them.

Clustering column is not necessary.

If clustering column is not given, partition column is used to sort the data in cassandra clusters.

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.