I want to use cassandra as a DB to store messages, when in my model messages are aggregate by channel. the 3 main important field of message:
- channel_id
- created_by
- message_id (unique)
The main read/fetch API is get messages by channel sorted by created_by
.
Plus, I have a low scale messages update by channel_id
+ message_id
.
So my question is regarding the primary_key definition.
If I will define it (channel_id,created_by)
will I be able to do an UPDATE
with WHERE
cLause like channel_id=X and message_id=XX
, even if message_id
is not in the primary key (I do give the query the partition key)?
And if not,
if I will define the primary key like this (channel_id,created_by, message_id)
will I be able to do the read with where cause with only 1 clustering column (channel_id,created_by)
and do the update using the where cause channel_id
+ message_id
?
Thanks