1
votes

I am new to Cassandra, I am confused between rowkey and partition key in Cassandra.

I am creating a table like:

Create table events( day text, hour text, dip text, sip text, count counter,
primary key((day,hour), dip, sip));

As per my understanding, in the above table day and hour columns form a partition key and dip,sip columns form a clustering key.

My understanding is that row key is nothing but partition key i.e. day, hour columns form a row key.

Is my understanding correct? Can any one clarify this?

1

1 Answers

4
votes

Is my understanding correct, Can any one clarify this?

Yes, your understanding is correct. The row key is the "old school" way of referring to a partition key. The partition key (as you probably understand) is the part of the CQL PRIMARY KEY which determines where the data is stored in the cluster. In your case, data within your partition keys will be sorted by dip and sip (your clustering keys).

You should give John Berryman's article Understanding How CQL3 Maps To Cassandra’s Internal Data Structure a read. It does a great job of explaining how your table structures map "under the hood."