Cassandra – Partition Key, Clustering key

Partition Key: It will be hashed and saved across nodes.
Clustering Key: It will group in the same partition key.

PRIMARY KEY((partion key), clustering key)
Example)
create table User(
email text,
name text,
desc text,
user_id uuid
PRIMARY KEY((email), name, user_id)
) WITH CLUSTERING ORDER BY (name DESC, user_id ASC);

Primary Key: email
Clustering Key: name, user_id

Reason of adding a user_id is to ensure the uniqueness of primary key.

Advertisements
This entry was posted in cassandra, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s