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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:29:03+00:00 2026-06-05T12:29:03+00:00

I am still new to PHP and I was wondering which alternative would be

  • 0

I am still new to PHP and I was wondering which alternative would be better or maybe someone could suggest a better way.

I have a set of users and I have to track all of their interactions with posts. If a users taps on a button, it will add the post to a list and if they tap it again, it will remove the post, so would it be better to:

Have a column of a JSON array of postIDs stored in the table for each user (probably thousands).

-or-

Have a separate table with every save (combination of postID and userID) (probably millions) and return all results where the userID’s match?

For the purposes of this question, there are two tables: Table A is users and Table B is posts. How should I store all of the user’s saved posts?

EDIT: Sorry, but I didn’t mention that posts will have multiple user interactions and users will have multiple post interactions (Many to Many relationship). I think that would affect Bob’s answer.

  • 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-05T12:29:05+00:00Added an answer on June 5, 2026 at 12:29 pm

    This is an interesting question!

    The solution really depends on your expected use case. If each user has a list of posts they’ve tagged, and that is all the information you need, it will be expedient to list these as a field in the user’s table (or in their blob if you’re using a nosql backend – a viable option if this is your use case!). There will be no impact on transmission time since the list will be the same size either way, but in this solution you will probably save on lookup time, since you’re only using one table and dbs will optimize to keep this information close together.

    On the other hand, if you have to be able to query a given post for all the users that have tagged it, then option two will be much better. In the former method, you’d have to query all users and see if each one had the post. In this option, you simply have to find all the relations and work from there. Presumably you’d have a user table, a post table and a user_post table with foreign keys to the first two tables. There are other ways to do this, but it necessitates maintaining multiple lists and cross checking each time, which is an expensive set of operations and error-prone.

    Note that the latter option shouldn’t choke on ‘millions’ of connections, since the db should be optimized for this sort of quick read. (pro tip: index the proper columns!) Do be careful about any data massage, though. One unnecessary for-loop will kill your performance.

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

Sidebar

Related Questions

I am still somewhat new to php and was wondering the best way to
I'm still new to JQuery, AJAX and PHP. I was wondering what I could
I am still new at PHP and the MVC concept. I have been trying
So, I'm still new with the php coding, still learning, etc. So, if this
still new to XML parsing with the iphone so i have a few questions.
I am still new to LINQ, and I have wrestled with a query for
I'm still new to Javascript and would like to create a 'pages' feature for
I'm wondering if there are any completely event-drive frameworks out there for PHP which
I'm still new to PHP/Javascript.I've made a simple Clock program in Javascript successfully. Now
I'm still pretty new to php and mysql, I've build a basic CMS for

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.