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

  • Home
  • SEARCH
  • 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 310707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:51:29+00:00 2026-05-12T07:51:29+00:00

I’m making a site with PHP and MySQL. The big idea is that you

  • 0

I’m making a site with PHP and MySQL. The big idea is that you can register and you can add objects to your profile. You can have only 1 profile, you can have multiple items(infinite, in theory) and each items can have multiple pictures(infinite, in theory).

I’m wondering how to best implement this in MySQL. I’ve had a very basic education on MySQL, in that I know how to make a table, what the various datatypes are, but things like foreign keys are something that’s buried in the back of my memory. I looked it up, but the understanding is coming a bit slow.

I could simply make 3 tables:

  1. Users_name + User_ID
  2. Item_ID + User_ID
  3. Item_ID + Picture_ID

Downside is that for every single search action, or profile view or even item view, I’d be querying the entire contents of the two last tables, which seems like overkill.

Can someone help me here?

  • 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-12T07:51:30+00:00Added an answer on May 12, 2026 at 7:51 am

    Your schema is actually pretty good. Now, your fear is that you’d query the entire contents of the tables. This is very much not true, given a good index on your primary and foreign keys!

    select
        u.users_name,
        i.itemid
    from
        users u
        inner join items i on
            u.user_id = i.user_id
    where
        u.user_id = 1234
    

    That rowset would return very quickly, even with hundreds of thousands of rows! The reason is because the query would use an index seek to find the row in users where that user_id is. Likewise once you join it to the items table. Therefore, it’s just two very quick lookups to find all of the items you’re looking for, and it won’t ever have to scan the tables.

    SQL is absolutely optimized for this stuff. Please take advantage of it!

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.