0
0
Redisquery~20 mins

Denormalization for speed in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Denormalization Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this Redis command sequence?
Given these Redis commands executed in order:

1. HSET user:1000 name "Alice" age 30
2. HSET user:1000:profile city "New York" country "USA"
3. HMGET user:1000 name age
4. HMGET user:1000:profile city country

What will be the combined output of commands 3 and 4?
Redis
HSET user:1000 name "Alice" age 30
HSET user:1000:profile city "New York" country "USA"
HMGET user:1000 name age
HMGET user:1000:profile city country
A["Alice", null] and ["New York", "USA"]
B["name", "age"] and ["city", "country"]
C["Alice", "30"] and ["New York", "USA"]
D[null, null] and [null, null]
Attempts:
2 left
💡 Hint
Remember that HMGET returns the values of the specified fields in the hash.
🧠 Conceptual
intermediate
1:30remaining
Why is denormalization used in Redis for speed?
Which of the following best explains why denormalization is commonly used in Redis to improve speed?
ADenormalization reduces the number of queries by storing related data together, avoiding expensive joins.
BDenormalization compresses data to use less memory, making queries faster.
CDenormalization encrypts data to improve security and speed.
DDenormalization automatically indexes all fields for faster search.
Attempts:
2 left
💡 Hint
Think about how Redis handles data and what it lacks compared to relational databases.
📝 Syntax
advanced
2:00remaining
Which Redis command syntax correctly denormalizes user and order data?
You want to store user data and their latest order details together in Redis for fast access. Which command correctly sets a hash with user info and embedded order info?
AHSET user:2000 name "Bob" age 25 order_id 1234 order_total 99.99
BHSET user:2000 name "Bob" age 25; HSET order:1234 total 99.99
CHMSET user:2000 name "Bob" age 25; SET order:1234 99.99
DHSET user:2000 name "Bob" age 25 order {id:1234, total:99.99}
Attempts:
2 left
💡 Hint
Redis hashes store flat field-value pairs; nested objects require flattening.
optimization
advanced
2:30remaining
How to optimize read speed with denormalized data in Redis?
You have user profiles and their recent activity logs stored separately. To optimize read speed for a dashboard showing both, what is the best denormalization strategy?
AUse Redis streams to store activity logs and join with profiles at query time.
BKeep user profiles and activity logs in separate keys and query both on demand.
CStore only user profiles in Redis and fetch activity logs from a relational database.
DStore user profile and recent activity fields together in one hash per user.
Attempts:
2 left
💡 Hint
Denormalization means combining related data to reduce queries.
🔧 Debug
expert
3:00remaining
Why does this denormalized Redis data retrieval fail?
You stored denormalized user data with order info as:

HSET user:3000 name "Carol" age 40 order_id 5678 order_total 150.00

But this command returns null:

HMGET user:3000 order

Why?
ABecause Redis hashes cannot store multiple fields with underscores.
BBecause 'order' is not a field; fields are 'order_id' and 'order_total', so HMGET 'order' returns null.
CBecause HMGET requires all fields to be numeric.
DBecause the key 'user:3000' does not exist.
Attempts:
2 left
💡 Hint
Check the exact field names stored in the hash.