Loading

Should I Save Images to Database or File System

Submitted by: 


It's been an issue for some time for developers the question of whether to save images on database or on file system. I decided to write this article to explain the pros and cons of both sides.
Saving Images To File System

Saving images to file system seems to be the best approach for some reasons. Images stored on file systems are easy to manage. When you need to retrieve the images, you just retrieve the path from your database and then load the image from there. They can also be easily previewed and this method separates your database information from image data. The down side of using file system to store images are the following:

* File system images can easily be renamed or deleted.
* File system images are susceptible to virus corruption (especially if you are running Windows)
* If your application is a web application, additional security measures must be done to secure images from unauthorized copying, linking etc...

Saving Images To Database

Images stored on database tables is applicable for images where database size is not a major concern, usually for applications which is expected to have just a minimum amount of information and would not require large concurrent connections. This gives you a centralized storage for all your applications resources. But for application which requires large amount of information, the database approach must be avoided for the following reasons:

* Saving images to tables bloats your database reducing performance
* Storing and retrieving images to tables requires additional programming techniques for converting images to byte array data and vice-versa.
* Images on database cannot be easily previewed.
* Dump files for your SQL Tables would consume large disk space.
* When databases are not well-structured and not maintained properly, bulky images can cause table/database corruption.

It is up to you whether to use the file system or the database approach. To me, I usually prefer the file system approach.




Comments

admin's picture

Yes you are right. This is always what I am saying to those who choose to ask this kind of question.

Thanks for this article.

By the way I will create a program on how to save and retrieve images to database. You can use this program if you have few images to store in your database.

But do not use this if you have a lot of images as what arjay have said.

nice post dear

If the application is big, and the size of images keep increasing daily, will you still using filesystem? What do you think, flick, myspace or facebook using? Filesystem or database to store the images?

just take data type of ms access database OLE object , in sql server there is option of image field

database is an organized collection of data, today typically in digital form. The data are typically organized to model relevant aspects of reality (for example, the availability of rooms in hotels), in a way that supports processes requiring this information (for example, finding a hotel with vacancies). See more at this site for further reading www.skilch.com

gorio
www.skilch.com

thanks for this article its great but please how I can use file system? Explain

rj-digital's picture

Nice article.

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.