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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:53:20+00:00 2026-06-14T02:53:20+00:00

I am creating a databsse for my site, which requires that multiple attachments be

  • 0

I am creating a databsse for my site, which requires that multiple attachments be uploaded by users in different pages. I wish to keep all those attachments in a single table and reference that table from other tables, where the attachment would be required.

Now the issue is how do I do this? I have not been able to work out the logic of it as yet. What I have in mind is:

attachment_tbl:
attach_id  
file_name
description
item1_id -> FK
item2_id -> FK


item1_tbl:
item1_id
attachment1
attachment2


item2_tbl:
item2_id
attachment1
attachment2
attachment3

Now how do I save all these attachments in the same table, without having multiple FK in the attachment_tbl, as if I add another item3_tbl, which has attachments, would it mean another FK to be added to the attachments_tbl?

Is there some other simpler and better way to do the same?

  • 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-14T02:53:21+00:00Added an answer on June 14, 2026 at 2:53 am

    Add a relationship table, which connects items and attachments, with a one to many relation:

    attachment_tbl:
    attach_id  
    file_name
    description
    
    item_tbl:
    item_id
    
    item_attachment_tbl:
    item_id -> FK
    attach_id -> FK
    

    For each attachment, there will be a row in the item_attach table:

    item_id attach_id
    -----------------
    item1   attach1
    item1   attach2
    item2   attach3
    item3   attach4
    item3   attach5
    item3   attach6
    

    When you want to see the attachments of an item, you must join the tables:

    select a.file_name, a.description
    from attachment_tbl a
    inner join item_attachment_tbl ia on a.attach_id = ia.attach_id
    where ia.item_id = 87;
    

    See also SQL Fiddle

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

Sidebar

Related Questions

I am creating a database that will help keep track of which employees have
I am creating a site on which content will be stored for several different
I am creating a Asp.Net site which will accept users' registration/logon. The Asp.Net MVC
What is a (free) technology which requires the least amount of code for creating
I am creating a web site which, among other things, databases pictures. For simplicity
I am creating a site-map with all urls on my site! I have a
I am currently creating a site(php,css,html,ajax,MySql) which will have heavy user usage of space(regarding
I'm creating a site which has a shopping cart. I do not need any
I am creating a site which you can post reminders. I have tried much,
Hi i am creating a windows phone 7.1 application, which requires in app purchases

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.