Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:12:27+00:00 2026-06-10T02:12:27+00:00

I’m trying to model data similar to amazon.com categories (e.g., books, movies, electronics, etc.)

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:12:29+00:00Added an answer on June 10, 2026 at 2:12 am

    Lets answer your question backwards.

    Storing Products in a Hash

    That is a good idea. In general, you want to store entities in a hashmap.

    Changing Category Names

    You should use an internal identifier for each category. Then store the category display name in a hashmap just like you store products. This indirection is useful – because it lets you store additional information for a category. For example, if you later decide to display “Most Popular Product” for each category, such a schema would be useful.

    Storing Products in Category

    You can create a key like category:books:products and then store the ids for each product. This can be a list, a set or sortedset – depending on what you want to do with the data.

    1. If there is an intrinsic order to the products, such as recently added products, then it makes sense to use a List. In this way, the first element in the list is the most recent product.
    2. If you want the products to be sorted on some criteria such as “most downloaded” or “most viewed”, you should use a sorted set.
    3. Use a Set if there is no other relationship between products in a category.

    Using a Set or SortedSet lets you perform intersections. These come in handy when you want a subset of items, such as ‘Books published by O’Reilly”. To do this, you will have to maintain another set “publisher:preilly” that contains book ids.

    Storing a collection of Categories

    Now, you suggested a SortedSet, which is one possible solution. But you can also use a list if the order of categories isn’t going to change dynamically. For example, if you always want to display categories in ascending order, a list is good enough.

    A SortedSet proves useful if the order will change dynamically. For example, if you want to display categories on the basis of the number of products in each category – then storing them in a SortedSet is a good idea.

    Also, remember, you can use several lists or sortedsets – each collection can represent a different use case. Lets assume you don’t want to sell books to overseas customers. In that case, you can have another key categories:overseas and store the categories you want to display.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.