Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

guruprasadb avatar image
guruprasadb asked ·

Is it ok to have multiple tables with the same partition key?

[FOLLOW UP QUESTION TO #10921]

Is it ok to have multiple tables with same partition key and different primary keys with Clustering order change? For example in Table 2 and Table 3 the hash will be on enterprise_id and will lead to same node. However only the clustering key order has changed and will allow me to query directly on the required key.

data modeling
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 ·

Yes, you can have multiple tables with the same partition key. The partition key of one table has nothing to do with the partition key of another table.

The partition key of a table simply determines the node where each partition is stored. The partitioner (the default is Murmur3Partitioner) runs a hash function on the partition key to convert it into a token. Whichever node in the cluster owns the token (based on its token range ownership) is responsible for storing the partition.

I've explained how the partitioner works in a bit more detail in my answer to question #5944. 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.