advancedTop 30 Scenario-Based Questions

Design a Cassandra schema for storing user activity events with the ability to query: 1) All events for a user in the last 7 days, 2) All events of a specific type today.

Two tables for two query patterns: Table 1 for query 1: CREATE TABLE user_events (user_id UUID, bucket DATE, event_time TIMESTAMP, event_type TEXT, payload TEXT, PRIMARY KEY ((user_id, bucket), event_time)) WITH CLUSTERING ORDER BY (event_time DESC) AND default_time_to_live = 604800; Query: WHERE user_id=? AND bucket IN [today, yesterday, ...7days...]. Table 2 for query 2: CREATE TABLE events_by_t

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to How do you implement optimistic concurrency control in MongoDB?← Back to all NoSQL questions