我是 Casssandra 的新手,我觉得很难实现数据模型。
我在设计一张桌子时遇到了很多问题。
在我提到表定义之前,我想向您展示我们必须检索和更新记录的方法
select * from email where username='suresh' and inactive='N' and type='outbound'
order by insert_ts desc allow filtering;
update email set inactive='Y' where username='suresh' and inactive='N'
and id=101;
要创建一个表,我应该遵循所有 cassandra 定义的规则。我在为表创建索引时遇到了问题
如果我像这样创建主键
PRIMARY KEY(username, inactive,type,insert_ts);
我能够检索记录,但是当我更新时,我收到错误消息“在集合中找到主键部分”错误。
如果我创建主键和辅助键,如下所示
PRIMARY KEY(username, type,insert_ts);
Secondary index = inactive;
我可以进行更新,但是当我检索时,我收到错误消息“二级索引将不允许使用 order by 子句”
我已经使用 cql 创建了电子邮件表,例如
Create table email(id int, username varchar, comment text,
inactive boolean, insert_ts timestamp, type varchar,
PRIMARY KEY(<<some columns yet to decide>>));
请建议我如何创建满足我查询的电子邮件表。