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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:59:27+00:00 2026-06-14T00:59:27+00:00

I have a website I develop that is structured a little like stackoverflow. I

  • 0

I have a website I develop that is structured a little like stackoverflow. I have a Posts table and a PostImages table in the database. The PostImages table looks like this:

PostImageId PK
PostId      FK
Uri
MimeType

So posts can have lots of images associated with them.

I now have the requirement that other places on the site should have images: Users should be able to have images on their profile, Categories should be able to have images, and Addresses should be able to have images.

It seems best to only have a single Images table in my database. How should I model this? I could have a single table like this:

ImageId    PK
PostId     FK
CategoryId FK
AddressId  FK
UserId     FK
Uri
MimeType

I could have a single images table, then extra tables for each kind of object:

PostImageId      PK FK
PostId           FK

CategoryImageId  PK FK
CategoryId       FK

(where the PK of each item is also FK to an image from the Images table)

There are some other strategies, too: for instance, I could have a ___Images table for each type, and no shared Images table. I could have a many-to-many mapping table for each, and perhaps there are some other solutions I haven’t thought of.

What is best? I don’t know that much about database design – which will be the most flexible and easiest to use?

  • 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-14T00:59:28+00:00Added an answer on June 14, 2026 at 12:59 am

    In real life projects, Database is designed regarding to the cost of accessibility of data. You mentioned two ways of designing your tables. Both are correct. If you put all your fields in one table there will be data redundancy. If you make two tables there is no problem.

    But you have to keep in mind that joining two tables will cost more. So while fetching data from your server, this may make your page slow (If concurrently a lot of users try at the same time).

    On the other hand, if you put it in one field, it will take more memory in database but less cost in data fetching. The choice is yours.

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

Sidebar

Related Questions

We have a web site with domain http://209.59.154.150/~phnxaudi/ ,. To develop this website we
I have this page table structure to store all the website page information, page_id
I have a job to develop a website. My client wants it so that
I have an existing website that I need to develop a small portion of
I am new to Jquery mobile I have develop a website that work fine
I'm helping a company develop a website that utilizes jquery but I have noticed
I develop a website in Sharepoint 2007. I have pages that have a richhtmlfield
We will develop a web site that will have some free services and we
I have been tasked to develop an interactive website using java & mysql: using
Hi i have develop and deploy one multilingual (english uk and swedish) website at

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.