I am still learning to understand Cassandra. I have read similar questions and answers on conversation messaging yet am not satisfied because it doesn't meet my needs. These are the problems i want to solve
- A user can send messages to one or many users
- A conversation tables - saves messages between user-user
- A conversation tables - Show recent conversation message for all users you have established conversation with, marked read or unread with a date.
- A conversation message tables - User A can load all conversations with user B or user C
- A conversation message tables - message sent will be marked read or unread
- A conversation message tables - User A can delete a message but user B message won't be deleted. very Important
I have the following tables
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) );
If user A id is 100, establishes conversation with user B and User B id is 101 then conversationid will be 100-101.
Please am new to Cassandra i want to know if my modelling is right.
If User A send a message to User B which conversation tables belongs to either User A or UserB
If user A established conversation with User B and User C establishes conversation with user A and user A wants to load all conversations with User C which conversation message table will the messages fetched from?
And how will i query conversation table to list all users, User A have established conversation with and all users who established conversation with user A containing the last message sent or receive.