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 7846243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:30:56+00:00 2026-06-02T17:30:56+00:00

An application has a MySQL database containing a table of Users. Each User has

  • 0

An application has a MySQL database containing a table of Users. Each User has it’s own Redis Hash. Each User-owned Redis Hash contains key/value pairs of question/answer strings. For example (in Ruby):

user = User.find(1)
question = "What colour is the sky?"
answer = "Blue"
user_hash = Redis::HashKey.new(user.id)
user_hash[question] = answer
user_hash[question] # returns answer

Now the User needs the ability to store multiple answers per question, for example:

question = "What colour is the sky?"
answers = ["Blue", "Grey", "Red"]

Also the application will perform methods on groups of questions/answers scoped through each User Hash, such as searching for User question strings containing certain words.

1) Is the Redis Hash the appropriate data type for the application at this point and, if so, 2) what is the best way to handle question/answer pairs with multiple answers?

  • 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-02T17:30:57+00:00Added an answer on June 2, 2026 at 5:30 pm

    You should think of these as 3 Objects – User, Question and Answer. Then, the relation between them becomes simple. User has Questions, Question has Answers.

    Now, it is easy to model this in Redis.

    • The objects User, Question and Answer are stored in a hash
    • Question will have fields like id, text, userid, date_asked, date_modified and so on
    • Answer will have fields like id, text, userid, questionid

    Then you need to store answers for a question. Create a Redis list with key question:$id:answers. This will be a list of answer ids.

    To search on the basis of keywords, you should create a Redis set for each keyword. In this Set, store ids for questions that contain this word.

    For example, sadd tag:java 123 232 4231 indicates that questions 123, 232 and 4231 have java in them. Similarly, add such a set for each keyword.

    Then, to filter questions that contain java and redis, just do a set intersection on tag:java and tag:redis.

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

Sidebar

Related Questions

My application has a table that contains snapshot inventory data from each year. For
I'm working with an application that has a MySQL database at Amazon RDS. The
Suppose I have a database containing 3 tables in a grails application: User Activity
Our application has a need to share an existing database table with another locally
I have a MySQL database in which table A has a one-to-many relation to
I am developing a Java Desktop Application which uses MySQL database. The DB has
Lets say we have a application which has a database - MySQL, SQL Server,
I'm building an Android application which has to sent some information to my mysql
I am creating a C++ application the uses a MySQL database. I would like
I had a question about where a MySql database has to sit for a

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.