hi i am new to Cassandra. I have little bit confusion in DB design in below scenario.
Currently i have 3 table : Post, User, PostLike.
Post : store post info
User : store user info
PostLIke :
CREATE TABLE PostLike (
like_time timestamp
post_id bigint,
user_id bigint,
PRIMARY KEY (like_time,post_id,user_id)
);
like_time : used to store post order by post like time. cassandra provide this in OrderPreservingPartitioner
requirement is:
All Users Id which like a given post order by like_time and got them using : select * from PostLike where post_id = ?
All posts liked by a user select * from PostLike where user_id = ? : it gave error
[Invalid query] message="PRIMARY KEY column "post_id" cannot be restricted (preceding column "ColumnDefinition{name=user_id, type=org.apache.cassandra.db.marshal.LongType, kind=CLUSTERING_COLUMN, componentIndex=0, indexName=null, indexType=null}" is either not restricted or by a non-EQ relation)"
pls suggest what i need to do here :
need to Use MySQL with Cassandra for these relation
OR
Create 2 separate table in cassandra
CREATE TABLE PostLike (
like_time timestamp
post_id bigint,
PRIMARY KEY (like_date,post_id)
);
CREATE TABLE UserLike (
like_time timestamp
user_id bigint,
PRIMARY KEY (like_date,user_id)
);
or any other solution. Please help.