This article is half-done without your Comment! *** Please share your thoughts via Comment ***
As a Database Architecture, this is my responsibility to write and share my knowledge on which one is best option to store images either into the Database System or into the File System?
I found this is most asking questions by Database Professional.
Let me discuss the all truth about these both option so Database Professional can take the right decision.
” The truth about to store images into the File System “
Store image into the File System and store the only path of that image into the Database System.
You can serve this images or pictures as static files across the network.
The Operating System can easily cache the image data for better access performance.
The management of files in the File System is very important, You have to manage proper folder structure, different schedule for taking the backup of all files.
If you are planning to migrate your application from one server to another at that time you also have to take the backup of not only image files, but you have to also maintain the same folder structure and path structure.
This is not advisable to store more than 3000 files into one folder, after some number of limit you should create a new folder for further files and this is advisable for performance aspect.
You can write an automated program to create the new folder structure.
The thumb rule of RDBMS is data integrity, If you are storing images in the file system, the image data disconnects with a database system.
You should also take care about a security of file directory, if someone deletes your image files, your application should throw an error like “Image is not found”.
” The truth about to store images into the Database System “
You can create a separate table or column for BLOB data type in which you can store images.
You can manage proper data integrity within the database system.
You need only one system to manage and perform any action like migration, replication.
You can take a full database backup with included all the image data, but this will take more time depends on the size of image data.
You can also commit image data like any other data.
The storing images into database system are very resource consuming.
Imagine, If you stored millions of images in the database and each size is around 60 KB, you have to use your SELECT statement properly otherwise this will create performance issues. You cannot put SELECT * in such a condition.
The image data is more secure in the database system because you can easily manage different privileges for users.
You can also create a dedicated server, database, schema for image data just like any other file server system.
If you are using SQL Server 2008, one new FileStream data type gives a very good optimized approach for storing files in a database system.
” Conclusion… “
You should take decision basis on your system complexity and scalability. I would suggest you go with File System. The Database Storage is not advisable, but still, people are using it.
Above are my views and concerns, but you should take a decision base on all the above facts.