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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:30:23+00:00 2026-06-05T07:30:23+00:00

In an relational database, i have an user table, an category table and an

  • 0

In an relational database, i have an user table, an category table and an user-category table which do many to many relationship.

What’s the form of this structure in Redis?

  • 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-05T07:30:24+00:00Added an answer on June 5, 2026 at 7:30 am

    With Redis, relationships are typically represented by sets. A set can be used
    to represent a one-way relationship, so you need one set per object to
    represent a many-to-many relationship.

    It is pretty useless to try to compare a relational database model to Redis
    data structures. With Redis, everything is stored in a denormalized way. Example:

    # Here are my categories
    > hset category:1 name cinema  ... more fields ...
    > hset category:2 name music   ... more fields ...
    > hset category:3 name sports  ... more fields ...
    > hset category:4 name nature  ... more fields ...
    
    # Here are my users
    > hset user:1 name Jack   ... more fields ...
    > hset user:2 name John   ... more fields ...
    > hset user:3 name Julia  ... more fields ...
    
    # Let's establish the many-to-many relationship
    # Jack likes cinema and sports
    # John likes music and nature
    # Julia likes cinema, music and nature
    
    # For each category, we keep a set of reference on the users
    > sadd category:1:users 1 3
    > sadd category:2:users 2 3
    > sadd category:3:users 1
    > sadd category:4:users 2 3
    
    # For each user, we keep a set of reference on the categories
    > sadd user:1:categories 1 3
    > sadd user:2:categories 2 4
    > sadd user:3:categories 1 2 4
    

    Once we have this data structure, it is easy to query it using the set algebra:

    # Categories of Julia
    > smembers user:3:categories
    1) "1"
    2) "2"
    3) "4"
    
    # Users interested by music
    > smembers category:2:users
    1) "2"
    2) "3"
    
    # Users interested by both music and cinema
    > sinter category:1:users category:2:users
    1) "3"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two relational tables: the Profiles table which contains 3 kinds of user
Let's imagine I have a relational database in which, among other things, I want
I have a very simple Rails app with a very simple relational database: Category
I have a database which takes user submitted data, the entries from which I
Can't seem to find a solution to this one. I have a relational table,
I have a table with a few relational columns and one XML column which
I have quite a problem concerning the use of relational database concepts in Delphi
Let's say I have rows of data retrieved from a relational database tables (perhaps
I Have 3 Relational Tables on SQLCE Database. Product       ProductCategory     ProductPhoto ----------
I have a question about Criteria method, one-to-many relation to the database, 'one' is

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.