一. 基本概念
1. Primary Key, Partition Key, Clustering Key
以下面的Table为例子:
create table sample(
k_part_one text,
k_part_two int,
k_clust_one text,
k_clust_two int,
k_clust_three uuid,
data text,
PRIMARY KEY((k_part_one,k_part_two),k_clust_one, k_clust_two, k_clust_three)
) with CLUSTERING ORDER BY (k_clust_one DESC, k_clust_two ASC);
Primary Key=Partition Key + Clustering Key, Partition Key是(k_part_one,k_part_two),Clustering Key是k_clust_one, k_clust_two, k_clust_three。
Partition Key决定了数据存储在集群的哪个节点,Primary Key决定数据在当前节点的排序。
2. 集合类型
1) set 如:set<text>, 有序集合 {'f@baggins.com', 'baggins@gmail.com'}
2) list 如:list<text>, 数组 ['rivendell', 'rohan' ]
3) map 如:map<timestamp, text>, 字典 { '2013-9-22 12:01' : 'birthday wishes to Bilbo', '2013-10-1 18:00': 'Check into Inn of Pracing Pony'}