Thanks Jeff for suggestions.

On Mon, Jul 10, 2017 at 9:50 PM Jeff Jirsa <jji...@apache.org> wrote:

>
>
> On 2017-07-10 07:13 (-0700), Siddharth Prakash Singh <sps...@gmail.com>
> wrote:
> > I am planning to build a user activity timeline. Users on our system
> > generates different kind of activity. For example - Search some product,
> > Calling our sales team, Marking favourite etc.
> > Now I would like to generate timeline based on these activities. Timeline
> > could be for all events, filtered on specific set of events, filtered on
> > time interval, filtered on specific set of events between time intervals.
> > Composite column keys looks like a viable solution.
> >
> > Any other thoughts here?
> >
>
> You probably want to take advantage of multiple/compound clustering keys,
> at least one of which being a timeuuid to give yourself ordering, and one
> giving you a 'type' of event.
>
> CREATE TABLE whatever (
> product_id uuid ,
> event_type text,
> event_id timeuuid,
> event_action text,
> event_data text,
> PRIMARY KEY(product_id, event_id, event_type, event_action, event_data));
>
> This will let you do "SELECT * FROM whatever WHERE product_id=?" and get
> all of the events, sorted by time, then by type, then you can have another
> unique "action", and finally a data field where you can shove your blob of
> whatever it is.  This would let you do time slices by specifying "event_id
> >= X and event_id < Y", but you'd need (want) to filter event_type client
> side.
>
> Alternatively, PRIMARY KEY(product_id, event_type, event_id, event_action,
> event_data) would let you do event_type=X and event_id >= Y and event_id <
> Z, which is all events of a given type within a slice.
>
> "product_id" may not be the natural partition key, feel free to use a
> compound partition key as well (may be "PRIMARY KEY((product_id,
> office_id), event_type, event_id, event_action, event_data)" to make a
> partition-per-office, as a silly example.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@cassandra.apache.org
> For additional commands, e-mail: user-h...@cassandra.apache.org
>
>

Reply via email to