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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:18:57+00:00 2026-05-27T21:18:57+00:00

I am working on a database design for a basic photo gallery which each

  • 0

I am working on a database design for a basic photo gallery which each user can upload several images.

Right now here is what I have:

photo_gallery

photo_id -    image             - sort_order - user_id
1        -    test.jpg          - 1          - 1
2        -    another_photo.jpg - 2          - 1

And then on my folder structure I would create a new folder like so:
images/photo-gallery/ and store the images in there. Now, should I create a folder for each user_id and store their specific images in that folder/

So in this case:
images/photo-gallery/1/test.jpg and all of user 1’s photos will be there?

Also for re-sizing, I am thinking about using smart image resizer so I can just store the original photo, and if I want to resize it to a certain size, I can just call it using the script like: /image.php?width=200&height=200&image=test.jpg.

Should I be hashing these file names? Am I missing anything else? Any suggestions on how to improve this?

Thanks!

  • 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-27T21:18:57+00:00Added an answer on May 27, 2026 at 9:18 pm

    Now, should I create a folder for each user_id and store their specific images in that folder?

    Yes, it would be a good idea to separate uploads in some way so you don’t end up with one directory holding tens of thousands of files. You could separate them by userid, by first letters (e.g. images/t/te/test.jpg), or by hash (e.g. images/0e/0e4fab12.jpg).


    Should I be hashing these file names?

    It depends on what you’re trying to accomplish. Since you’re planning to refer to the filenames in a URL, storing the filename with a known set of “safe” characters can be an advantage:

    image.php?image=c/ca/cat%20farting%20On%20a%20lemon.jpg
     -- vs --
    image.php?image=0a/0a1b2c3d.jpg
    

    If you do this, however, I would suggest extending your database schema to include the original filename:

    photo_id | image           | orig_fn           | sort_order | user_id
    1        | 0a/0a1b2c3d.jpg | charginLazors.jpg | 1          | 2
    

    You might also consider storing additional metadata about the image, such as the upload date, a caption, etc.


    Regarding the folder structure, you can use any number of characters from the filename, though there are some things to consider:

    Using a hashing method that creates hexadecimal filenames means your maximum number of subfolders will be a multiple of 16:

    • One character — 16 subfolders
    • Two characters — 256 subfolders
    • Three characters — 4096 subfolders

    If you use more than two characters, I’d suggest nesting the folders even further: 0a/0a12/0a12bd31.jpg -or- 0a/12/0a12bd31.jpg. This makes navigating/managing the files a bit more manageable (IMO)

    Keep in mind that the more prefixed characters you use, the less files will be in each folder. If you’re expecting high volume, you might choose to have more folders with less files per folder.

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

Sidebar

Related Questions

I am working on an app right now which has the potential to grow
I am working on a Class Registration database design. Courses have multiple sections. Each
I'm working on a database design for groups hierarchy used as the foundation of
I'm working on a database design for an e-commerce web application. For this question
hey everyone... so i'm working on a database design class for university. I've got
I am working on the design of a database that will be used to
I've been working on database-driven web applications for a few years now and recently
I'm working on a database design for a Java web application work flow app
I have a question related to database design. The database that I'm working with
I'm trying to design a database for a small project I'm working on. Eventually,

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.