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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:29:02+00:00 2026-06-12T15:29:02+00:00

The think I’m trying to implement is an id table. Basically it has the

  • 0

The think I’m trying to implement is an id table. Basically it has the structure (user_id, lecturer_id) which user_id refers to the primary key in my User table and lecturer_id refers to the primary key of my Lecturer table.

I’m trying to implement this in redis but if I set the key as User’s primary id, when I try to run a query like get all the records with lecturer id=5 since lecturer is not the key, but value I won’t be able to reach it in O(1) time.

How can I form a structure like the id table I mentioned in above, or Redis does not support that?

  • 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-12T15:29:03+00:00Added an answer on June 12, 2026 at 3:29 pm

    One of the things you learn fast while working with redis is that you get to design your data structure around your accessing needs, specially when it comes to relations (it’s not a relational database after all)

    There is no way to search by “value” with a O(1) time complexity as you already noticed, but there are ways to approach what you describe using redis. Here’s what I would recommend:

    • Store your user data by user id (in e.g. a hash) as you are already doing.
    • Have an additional set for each lecturer id containing all user ids that correspond to the lecturer id in question.

    This might seem like duplicating the data of the relation, since your user data would have to store the lecture id, and your lecture data would store user ids, but that’s the (tiny) price to pay if one is to build relations in a no-relational data store like redis. In practical terms this works well; memory is rarely a bottleneck for small-ish data-sets (think thousands of ids).

    To get a better picture at how are people using redis to model applications with relations, I recommend reading Design and implementation of a simple Twitter clone and the source code of Lamernews, both of which are written by redis author Salvatore Sanfilippo.

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

Sidebar

Related Questions

Think my problem is I am trying to sum a count in the same
Think Google Chrome's Inspect Element. When a user mouses over a line in Developer
Think google have a limitation for user , so users have to login to
Think you are the proud owner of Facebook, then which data you want to
Think of it as more of a collection of elements which are not necessarily
I think this has probably been asked, but after reading a lot, I'm not
Think about a rectangular div, which is split into 2 parts, each part is
I think I have a fairly basic question here. I'm not trying to waste
Think about the games like Spiral Knights and Minecraft(Which I believe both use LWJGL)
I'm trying to select an H1 element which is the second-child in its group

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.