Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在cassandra中跨表更新冗余值_Cassandra - Fatal编程技术网

在cassandra中跨表更新冗余值

在cassandra中跨表更新冗余值,cassandra,Cassandra,假设我的用户分布在这些表中: user_notifications ( user_name user_url notification_text notification_date PRIMARY KEY(user_name, notification_date) ) user_profiles ( user_name PRIMARY KEY user_url birth_date ..etc ) 现在,当用户更新他们的信息时,这应该如何工作?是否同时更新

假设我的用户分布在这些表中:

user_notifications (
  user_name 
  user_url
  notification_text
  notification_date
 PRIMARY KEY(user_name, notification_date)
)

user_profiles (
  user_name PRIMARY KEY
  user_url
  birth_date
  ..etc
)
现在,当用户更新他们的信息时,这应该如何工作?是否同时更新这两个表?如果我的模式增长并且有10多个表,如何跟踪冗余用户信息的存储位置?有这样的模式吗?我可以想到一种存储库模式,其中包含所有这些语句,但我不确定这是否是正确的方法。

使用。批处理语句将减少网络往返,并确保原子性

例如:

BEGIN BATCH
  INSERT INTO purchases (user, balance) VALUES ('user1', -8) USING TIMESTAMP 19998889022757000;
  INSERT INTO purchases (user, expense_id, amount, description, paid)
    VALUES ('user1', 1, 8, 'burrito', false);
APPLY BATCH;

那么,如果我只有一个主键可用,比如user_name,并且希望批量更新通知记录,该怎么办?这将如何工作?取决于应用程序的结构。在这种情况下,您可能必须为
用户名
通知日期
使用反向索引。在cassandra中使用的技巧是围绕查询设计一个表,而不是在查询优化数据模型(cassandra的数据模型)中为表设计查询。您的数据没有规范化,表设计应该面向优化查询。批处理语句使您能够插入多个分区,并确保任何更改的原子性。感谢您的帮助。非常感谢。:)