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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:52:13+00:00 2026-05-25T22:52:13+00:00

Well lately I’m making a script application. People can post and share stuff (let’s

  • 0

Well lately I’m making a script application. People can post and share stuff (let’s call them object for the purpose of the question). Thing is, that a user can “bookmark an object” in his profile.

I have a table for users with unique uid (primary key) and a table for objects with a unique oid (primary key). I was thinking of making a new table in MySQL, calling it liked_objects which will have the following:

id – oid – uid

Each time I need to find all the object that user X liked I may run a query

SELECT * FROM liked_objects WHERE uid = userXid

My question is: Is there a most efficient way of doing this?

I’m using PHP 5 and MySQL Database.
Best regards

  • 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-05-25T22:52:14+00:00Added an answer on May 25, 2026 at 10:52 pm

    You don’t need an id column for your liked_objects table. Assuming a user can only like each object once, you can just use two columns:

    uid | oid

    Make the Primary Key be both columns. Then to unlike an object you just:

    DELETE FROM `liked_objects` WHERE uid = 'user_id' AND oid = 'object_id'

    To like an object you:

    INSERT INTO `liked_objects` (`uid`, `oid`) VALUES('user_id', 'object_id')

    And you can select the liked objects the way you said.

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

Sidebar

Related Questions

Well, this is my first post here and really enjoying the site. I have
Well, it seems simple enough, but I can't find a way to add a
Lately, I've been reading much about constructors from the well-received C++ FAQ . One
Lately I've been taking a look at Haxe , to build an application to
I have a simple SDI app which works pretty well. Lately I decided to
I run a website which shows related articles widget that people can add on
Lately I read this post: How do I use boost.lambda with boost.thread to get
I've begun writing stuff in markdown lately, and edit my files in SciTE. I
I was reading and hearing some stuff about cloud computing and map-reduce techniques lately.
So I have this code running pretty well.. lately.. and I need to select

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.