I'm beginner in case of Cassandra database. I have prepared example of event store table, which looks like the following:
CREATE TABLE IF NOT EXISTS eventstore.Event(
Id uuid,
Data text,
Version int,
AggregateId uuid,
EventIdentity uuid,
Date timestamp,
PRIMARY KEY (AggregateId, Version)
) WITH CLUSTERING ORDER BY (Version ASC)
Where:
Id -> Unique GUID for each event
Data -> JSON event data
Version -> int value of event version
AggregateId -> as named, Id of Aggregate
EventIdentity -> Id of Event type
Date -> timestamp when Event occurred
I am not sure if my Primary key is correct (AggregateId,Version) and also Clustering by Version. I'm wondering if my table will be partitioned correctly. Partition by AggregateId which contains all events for this aggregate ordered by Version.