Challenge - 5 Problems
Redis Embedding vs Referencing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Embedding in Redis
In Redis, embedding data means storing related information together in a single key. Which of the following best describes a scenario where embedding is beneficial?
Attempts:
2 left
💡 Hint
Think about when you want to access all related data quickly without multiple lookups.
✗ Incorrect
Embedding groups related data in one place, which is efficient when you often need all that data together. Option D shows this by combining profile and recent activity in one hash.
🧠 Conceptual
intermediate2:00remaining
When to Use Referencing in Redis
Referencing in Redis means storing related data separately and linking them by keys or IDs. Which situation is best suited for referencing?
Attempts:
2 left
💡 Hint
Consider when data is shared or reused in multiple places.
✗ Incorrect
Referencing is ideal when data is reused or shared, like product details referenced by many shopping carts. This avoids duplication and keeps data consistent.
❓ query_result
advanced2:00remaining
Result of Embedded Data Retrieval
Given a Redis hash key 'user:1000' storing embedded data: {"name":"Alice", "age":"30", "city":"NY"}, what is the output of the command: HGETALL user:1000 ?
Redis
HGETALL user:1000Attempts:
2 left
💡 Hint
HGETALL returns all fields and values as strings in an array.
✗ Incorrect
HGETALL returns all fields and values in the hash as an array of strings. Option B matches the exact output format.
❓ query_result
advanced2:00remaining
Output of Referencing Data Retrieval
Assume you have two Redis keys: 'product:200' with value '{"name":"Book", "price":"15"}' and 'cart:300' storing a list of product IDs ['200', '201']. What is the output of LRANGE cart:300 0 -1 ?
Redis
LRANGE cart:300 0 -1
Attempts:
2 left
💡 Hint
LRANGE returns elements of a list as stored, not the referenced data.
✗ Incorrect
LRANGE returns the list elements as strings. It does not fetch referenced data automatically. So it returns the product IDs stored in the list.
❓ schema
expert3:00remaining
Designing Redis Schema for Mixed Embedding and Referencing
You want to design a Redis schema for an e-commerce app where user profiles embed contact info but reference orders separately. Which schema design below correctly follows this approach?
Attempts:
2 left
💡 Hint
Embedding contact info means storing it directly in user profile; referencing orders means separate keys.
✗ Incorrect
Option A correctly embeds contact info in user hash and references orders separately by storing order IDs in separate lists. This balances embedding and referencing.