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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:21:37+00:00 2026-06-08T12:21:37+00:00

How would I set up a table for topics that a user likes? I

  • 0

How would I set up a table for topics that a user likes? I have a topics tables and a user table (more actually but simplified for a post on here). There is an ever increasing number of topics as they are user generated, how could I allow users to like pages? Would i put the topic’s id in the user table or the user’s id in the topics table or a create a new likes table? The issue I see is that the number of topics could (potentially) be very large. What could I use to create a system that allows a relationship between a users id and the topics id?

  • 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-08T12:21:38+00:00Added an answer on June 8, 2026 at 12:21 pm

    What you could possibly do is a “many to many” table structure

    • A unique auto incremented id – UINT (10) AUTO_INCREMENT
    • A feild containing the user id – UINT (10) (or what ever matches your main user_id field)
    • A field containing the “liked” topic id – UINT (10) (or what ever matches your main topic_id field)

    Both user_id and topic_id fields would need to be unique together. That means that there can only be once row for a specific like per user. This makes sure (on the database side), that a user will not be allowed to like a topic more than once.

    Getting a users liked topics would look like this –

    SELECT * FROM user_likes` WHERE `user_id`=USER_ID
    

    Getting the users per like would look like this –

    SELECT * FROM user_likesWHEREtopic_id`=TOPIC_ID


    As others have said in their answers and also @trevor in the comments below –

    Don’t forget to add an index on the userid to support retrieval of user liked topics and a separate index on topic is to support the topics per user query – without these, the queries will get slower as more data is added over time.

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

Sidebar

Related Questions

I have a BeanDefinitionDecorator that makes modifications to properties that a user would set
If I have a table of a hundred users normally I would just set
I have a table and I would like to be able to set up
I have a table that self references to create a hierarchy. CREATE TABLE [dbo].[Topics](
We would like to reserve a set of primary key identifiers for all tables
I have two tables, subscriptions and topics. Each subscription is related to a specific
I'm trying to set up a simple login using AuthLogic into my User table.
I am using JqGrid with javascript. I would set the height of each table
I know that there are quite a few different topics out there but I
I have a JTable where I have set table.setAutoCreateRowSorter(true); . My main objective 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.