我还在学习理解 Cassandra . 我已经阅读了有关会话消息的类似问题和答案但却不满意,因为它不符合我的需求 . 这些是我想要解决的问题
-
用户可以向一个或多个用户发送消息
-
会话表 - 在用户 - 用户之间保存消息
-
对话表 - 显示与您 Build 对话的所有用户的最近对话消息,标记为已读或未读日期 .
-
会话消息表 - 用户A可以加载与用户B或用户C的所有会话
-
会话消息表 - 发送的消息将标记为已读或未读
-
对话消息表 - 用户A可以删除消息,但不会删除用户B消息 . very Important
我有以下表格
CREATE TABLE user (
username text PRIMARY KEY,
password text
);
CREATE TABLE friends (
username text,
friend text,
since timestamp,
PRIMARY KEY (username, friend)
);
CREATE TABLE followers (
username text,
follower text,
since timestamp,
PRIMARY KEY (username, follower)
);
CREATE TABLE conversation_A (
participantA text,
participantB text,
conversationid text,
message text,
read boolean,
date timestamp,
PRIMARY KEY(participantA, date)
);
CREATE TABLE conversation_B (
participantA text,
participantB text,
conversationid text,
message text,
read boolean,
date timestamp,
PRIMARY KEY(participantA, date)
);
CREATE TABLE conversation_message_sent (
conversationid text,
messageid bigint,
sender text,
recipient text,
message text,
read boolean,
date timestamp,
PRIMARY KEY(conversationid, date)
};
CREATE TABLE conversation_message_receive (
conversationid text,
messageid bigint,
sender text,
recipient text,
message text,
read boolean,
date timestamp,
PRIMARY KEY(conversationid, date)
};
CREATE TABLE messages_sent (
messageid bigint,
message text,
date timestamp,
PRIMARY KEY(messageid, date)
);
CREATE TABLE messages_receive (
messageid bigint,
message text,
date timestamp,
PRIMARY KEY(messageid, date)
);
如果用户A id为100,则与用户B Build 会话,用户B id为101,则conversationid为100-101 .
请新来的Cassandra我想知道我的造型是否正确 .
如果用户A向用户B发送消息,哪些会话表属于用户A或用户B.
如果用户A与用户B Build 了对话,并且用户C与用户A Build 了对话,并且用户A想要加载与用户C的所有对话,那么会从哪个对话消息表中获取消息?
我将如何查询会话表以列出所有用户,用户A已与所有与用户A Build 对话的用户 Build 了对话,用户A包含发送或接收的最后一条消息 .
1 回答
你也可以添加头像网址和其他东西
参与者现在对我来说没用,但它没有麻烦得到更多的信息,
这应该写两次(从和交换)以便于阅读查询,你需要有2种删除(deleted_from和deleted_to),它涵盖了你的最后一个问题点
我用它作为消息的第一页,它只显示最后一条消息
这是我得到的消息应用程序我正在努力,有一些不同的btw我和你的原因你没有这样的线程的东西,但你可以实现我做了什么适合你