I want to experiment using Cassandra as an event store in an event search application. My event storage requirements are pretty simple. The circuit event will be something like this:
- id : aggregate root object id
- data : serialized event data (e.g. JSON)
- timestamp : when the event occurred
- sequence_number : unique version of the event
I am completely new to Kassandra, so forgive me for my ignorance of what I am going to write. I have only two queries that I would ever like to use for this data.
- Give me all the events for the given root root id
- Give me all the events for this aggregate root if the sequence number is → x
My idea is to create a Cassandra table in CQL as follows:
CREATE TABLE events ( id uuid, seq_num int, data text, timestamp timestamp, PRIMARY KEY (id, seq_num) );
Does this seem like a reasonable way to model a problem? And what's important, does the composite primary key use it to efficiently execute the queries I asked? Remember that if used, there may be a large number of events (with a different seq_num) for the same root root identifier.
My particular concern is that the second query will be inefficient in some way (I think of secondary indexes here ...)
cassandra
DrewEaster
source share