I'm trying to model data similar to amazon.com categories (e.g., books, movies, electronics, etc.) in a Redis database. Order matters to me when they're rendered on an HTML page so that the user is presented with a consistent user interface. As such, I stored the categories in a Sorted Set:
ZADD categories 0 "Books"
ZADD categories 1 "Movies"
ZADD categories 2 "Electronics"
I then created another Sorted Set for each of the sub-categories.
ZADD categories:books 0 "Fiction"
ZADD categories:books 1 "Non-Fiction"
ZADD categories:movies 0 "Horror"
[...]
From here, I figured I could store products in a Hash.
HMSET product:1000 category 0 subcategory 0 title "Redis Cookbook"
HMSET product:1001 category 1 subcategory 0 title "Nightmare on Elm Street"
[...]
I'm very new to both Redis and Key/Value database stores, so I'm anything but confident in my approach. Is this model going to work for me long-term? Is there a better/alternative approach I should be aware of? One concern I have is keeping the names "synchronized". For example, if I change the top-level category from "Books" to "Literature" (terrible example, I know) all of the keys for the sub-categories that "reference" books should also be updated.