0
0
Redisquery~10 mins

Embedding vs referencing in Redis - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to store a user profile with embedded address data in Redis using a hash.

Redis
HSET user:1000 name "Alice" [1] "123 Main St" city "Springfield"
Drag options to blanks, or click blank then click option'
Astreet
Baddress
Clocation
Daddr
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic term like 'address' which might be confusing in a hash.
Using abbreviations that are unclear.
2fill in blank
medium

Complete the code to reference an address stored separately by its ID in Redis.

Redis
HSET user:1001 name "Bob" address_id [1]
Drag options to blanks, or click blank then click option'
Aaddress:200
Baddr200
Caddress_200
Daddr:200
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys without colon separators which is less common in Redis.
Using inconsistent naming conventions.
3fill in blank
hard

Fix the error in the code that tries to embed a list of phone numbers directly in a Redis hash.

Redis
HSET user:1002 name "Carol" phones [1]
Drag options to blanks, or click blank then click option'
A"[123-4567, 234-5678]"
B"123-4567;234-5678"
C"123-4567,234-5678"
D"123-4567 234-5678"
Attempts:
3 left
💡 Hint
Common Mistakes
Using JSON-like arrays which Redis hashes do not support.
Using semicolons or spaces which are less standard separators.
4fill in blank
hard

Fill in the blank to create a Redis command that retrieves the city from the referenced address hash.

Redis
HGET [1] city
Drag options to blanks, or click blank then click option'
Aaddress_300
Baddress:300
Cuser:city
Duser:300
Attempts:
3 left
💡 Hint
Common Mistakes
Using the user key instead of the address key.
Using underscores instead of colons in keys.
5fill in blank
hard

Fill all three blanks to create a Redis Lua script snippet that fetches a user name, then fetches the city from the referenced address hash.

Redis
local userKey = [1]
local addressKey = redis.call('HGET', userKey, [2])
return redis.call('HGET', addressKey, [3])
Drag options to blanks, or click blank then click option'
A'user:400'
B'address_id'
C'city'
D'name'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field names like 'name' instead of 'address_id' for the reference.
Mixing up the order of commands.