0
0
Redisquery~20 mins

Why data modeling differs in Redis - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Data Modeling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does Redis data modeling differ from traditional relational databases?

Redis is a key-value store with different data structures than relational databases. Which reason best explains why data modeling in Redis differs?

ARedis supports various data structures like lists, sets, and hashes, requiring different modeling approaches.
BRedis uses tables and rows like relational databases, so modeling is the same.
CRedis stores data as simple strings only, so complex models are impossible.
DRedis automatically converts all data into JSON format, so modeling is standardized.
Attempts:
2 left
💡 Hint

Think about the types of data Redis can store beyond simple strings.

query_result
intermediate
2:00remaining
What is the output of this Redis command sequence?

Given the following Redis commands, what is the output of LRANGE mylist 0 -1?

LPUSH mylist "apple"
LPUSH mylist "banana"
LPUSH mylist "cherry"
A["banana", "apple", "cherry"]
B["apple", "banana", "cherry"]
C["cherry", "banana", "apple"]
D[]
Attempts:
2 left
💡 Hint

Remember that LPUSH adds elements to the head (left) of the list.

📝 Syntax
advanced
2:00remaining
Which Redis command syntax correctly adds a member to a set?

Choose the correct Redis command syntax to add the member "orange" to the set "fruits".

ASET fruits orange
BLPUSH fruits orange
CADD fruits orange
DSADD fruits orange
Attempts:
2 left
💡 Hint

Sets in Redis use a specific command to add members.

optimization
advanced
2:00remaining
How to optimize Redis data modeling for fast retrieval of user sessions?

You want to store user session data in Redis for quick access. Which data modeling approach is best for fast retrieval by session ID?

AStore each session as a separate key with a hash containing session fields.
BStore all sessions in a single large list and scan it to find sessions.
CStore sessions as JSON strings in a sorted set with timestamps as scores.
DStore sessions in a Redis stream and read all entries sequentially.
Attempts:
2 left
💡 Hint

Consider how to quickly access a session by its unique ID.

🔧 Debug
expert
3:00remaining
Why does this Redis Lua script fail to update a hash field?

Given this Lua script run in Redis, why does the field "count" not update as expected?

local key = KEYS[1]
local field = ARGV[1]
local increment = tonumber(ARGV[2])
local current = redis.call('HGET', key, field)
if not current then
  current = 0
else
  current = tonumber(current)
end
redis.call('HSET', key, field, current + increment)
AThe script does not return any value, so the update is not saved.
BThe script does not handle the case when the existing field value is non-numeric correctly.
CThe script uses HSET instead of HINCRBY, causing the update to fail.
DThe variable 'current' is not converted to a number before addition.
Attempts:
2 left
💡 Hint

Check what happens if the field exists but contains a non-numeric value.