Cassandra 入门

一. 基本概念

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>,  有序集合 {'[email protected]', '[email protected]'}

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'}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值