Design question - saving images as objects

Ok, so my site focuses on a lot of dynamic custom images for different user defined objects. So I have a lot of objects and these objects have images.

Is it okay to handle images like the object since the Image Title and Image Byte columns are repeated many times? Or, it makes more sense to just include those two columns in the tables for each object.

I guess I am answering my own question while typing ... I am creating an extra join and an extra column (there will be three in each table with names, IDs and ImageId "

however there are multiple tables with multiple images per object ... so i think it would be better ???? Opinions?

+1


source to share


3 answers


I usually have a file table where files are stored more universally. Then in your other tables, you can have a column for each image (file) that is just a link to the file table.

Your file table will have all the usual things like ID, filename, size, type, etc. Then yes, you just join it to get what you need for whatever request you ask for.



In case of any doubt, I strongly discourage you from storing files directly in the database. I don't think your post is, but if anyone else gets the idea, just don't!

+4


source


Question: "I have several objects with the same image." If so, then you might want to consider redundancy. Also, is the database using the "blobs" descriptor well used? Or would it be better to keep the file path and keep the images separate>



0


source


Intuitively, I would find it easier to deal with images and objects as separate concepts. It just feels more flexible.

If you need to attach things other than images to specific objects, it becomes as simple as linking the object table record to the β€œother things” table record, although you may have to change how the foreign key is specified. It will also give you the ability to use these images in other user objects or allow users to borrow images from other users.

The downside to this approach is that you pay a little performance penalty for having to join one or more tables. This is probably not the biggest deal if your database query parser is reasonably sane.

0


source







All Articles