There seems to be a lot of "how to... images in databases" questions.

What are the Pros and Cons of this Vs good old fashioned images in folders?

Recommended Answers

All 2 Replies

As usually is the case with this kind of question...It depends.

I think the only good case nowadays (what with filestorage being quick and cheap) is when you need to control and maintain links to image metadata. Doing this in a database is much easier and provides a little redundancy over the metadata contained within the file itself. This also means you can strip metadata from the file for whatever reason.

Otherwise, I think it would be best to store images on the normal file system. File systems are good at what they do and will offer you the data at a reasonably fast speed and in higher quantity (unless you're going to problem parallel queries, your database is going to be hit one at a time)

If you store all of your images in a database (essentially in one file) then you lose access to all of the images if the database somehow gets corrupted (it can happen more easily than you think). If, however, you store all the images ini separate files, you only lose the specific images that get corrupted. If one file gets trashed it doesn't affect the others. Of course, someone is bound to post what if the disk gets trashed. Yes, that can happen, but if it does happen you lose your files whether they are stored in a database or in separate files so that argument is irrelevant.

Also, storing massive amounts of numerical/textual data in a database facilitates doing data mining operations on that data. What advantages are there for keeping images in a database rather than in a file structure? If they are in a database then you MUST go through the database to access them. If they are in a file structure you can access them through your applicatiion of choice.

Having the files in a file structure allows ad-hoc processing without requiring that a user have database software installed on their computer. Let's take an example from my former place of employment. We might have a large number of photos taken at our generating stations. If a user wants to know if we have any photos of the Pine Falls generating station construction from 1950. Assuming that the photos have been properly labeled the user could simply have Windows scan the folder structure for files containing "1950" and "Pine Falls". In a database the user would have to contact some IT person to do the query and wait for the results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.