mannyson Posted August 28, 2015 Share Posted August 28, 2015 I am curious to know what the best practice is for something like this. I as a user post a record. In that record is an option for me to upload images. Since I am storing my record in "records" table, is it a good idea to ALSO store the record images(file paths) in the same table? Or would it make more sense to store the images is a separate table called "images"? Quote Link to comment Share on other sites More sharing options...
gizmola Posted August 28, 2015 Share Posted August 28, 2015 If a user can have multiple images uploaded, then the relationship is 1 record -> to many images. This requires that you have a separate images table with the foreign key of record_id to link the image back to its user. Quote Link to comment Share on other sites More sharing options...
mannyson Posted August 28, 2015 Author Share Posted August 28, 2015 If a user can have multiple images uploaded, then the relationship is 1 record -> to many images. This requires that you have a separate images table with the foreign key of record_id to link the image back to its user. Yes the record will have multiple images. So I guess it's best to separate them. Thanks. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 29, 2015 Share Posted August 29, 2015 In addition to Gizmola's advice I suggest that you do NOT store the actual image files (.jpg,.png,.gif, etc.) in a table. No need for that. Store the location/name of the image file in your record and save the image file in that place. If the images are going to be displayed on your html pages, then store them in the web-accessible tree. As for your paths - if you have control over the images and directory structure I would keep the path to the folder(s) as a constant for your appl and just use a relative path in the record. Then when things get moved around for some reason you simply create a new tree and copy the old one under it and then modify the appl constant to point to the new location. All the relative paths in the records will still work just fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.