MySQL Database – Multiple Images

20 pts.
Tags:
MySQL
MySQL Database
Hi, I am going to build a database soon for a website that can grow tremendously in the long run when it comes to the amount of records being added. This will be a MySql Database integrating with a Flash website. My main question is how should I handle multiple images being uploaded. A user will be able to post a maximum amount of 5 images and a required minimum of 3. I would be storing the images on the server and not in the database. I don't know what would be the most efficient way to store and retrieve the image file link information though. The way I figured it, is to have the users table with all their normal information. This table will contain a good amount of fields. Then create a table say profile images with the following fields: Image_profile_id User_id Image_slot_1 Image_slot_2 Image_slot_3 Image_slot_4 Image_slot_5 Is this a good way to approach this? Thanks in advance for the feedback.

Answer Wiki

Thanks. We'll let you know when a new response is added.

With this design, if your requirements about the max number of images per user change in the future, you would have to add (or remove) columns to (from) your table, so I would probably not recommend this approach.

How about something like this for the second table:

<pre>User_id
Image_no
Image_url</pre>

This way, you could have any number of images per user if needed without the need to modify your table structure. Then you could store the max number of images allowed for each user in some other table, where you store general parameters for your system.

————————-

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Heato112
    Ah yes you bring up a great point, I forgot to ask that in my question as well. I was worried about the min, max numbers changing. Thanks for the advice, I really appreciate it.
    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following