【发布时间】:2015-10-22 02:53:50
【问题描述】:
我有这些表
CREATE TABLE user_info (
userId uuid PRIMARY KEY,
userName varchar,
fullName varchar,
sex varchar,
bizzCateg varchar,
userType varchar,
about text,
joined bigint,
contact text,
job set<text>,
blocked boolean,
emails set<text>,
websites set<text>,
professionTag set<text>,
location frozen<location>
);
create table publishMsg
(
rowKey uuid,
msgId timeuuid,
postedById uuid,
title text,
time bigint,
details text,
tags set<text>,
location frozen<location>,
blocked boolean,
anonymous boolean,
hasPhotos boolean,
esIndx boolean,
PRIMARY KEY(rowKey, msgId)
) with clustering order by (msgId desc);
create table publishMsg_by_user
(
rowKey uuid,
msgId timeuuid,
title text,
time bigint,
details text,
tags set<text>,
location frozen<location>,
blocked boolean,
anonymous boolean,
hasPhotos boolean,
PRIMARY KEY(rowKey, msgId)
) with clustering order by (msgId desc);
CREATE TABLE followers
(
rowKey UUID,
followedBy uuid,
time bigint,
PRIMARY KEY(rowKey, orderKey)
);
我在 BATCH 中执行 3 INSERT 语句,将数据放入
publishMsgpublishMsg_by_userfollowers表中。要显示一条消息,我必须在不同的表上查询三个 SELECT 查询:
publishMsg - 获取发布消息的详细信息,其中rowkey 和msgId 给出。
userInfo - 基于postedById 得到fullName
followers - 了解postedById 是否关注给定主题
这是使用 cassandra 的合适方式吗?由于给定的 scanerio 数据无法放入单个表中,这会不会很有效。
【问题讨论】:
-
追随者中的“rowKey”意味着什么?是特定消息的关注者,还是特定用户的关注者?
-
啊,一定是用户的。当您说“显示一条消息”时,为什么需要了解用户的关注者?
-
在
followersrowKey中是一些主题,后面是ID 为followedBy的用户。所以从这张表中我想知道给定的用户是否关注给定的主题
标签: cassandra cql cassandra-2.0 datastax