As a Database Architecture this is my responsibility to write and share my knowledge about, which one is best option to store images either into the Database System or into the File System.
I have found this is most asking questions by Database Professional. Let me discuss all truth about this 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 only path of that images 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 scheduler for backing all files.
- If you are planning to migrate your application from one server to another at that time you have to also take 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 file into one folder, after some number of limit you can create a new folder for further files and this is advisable for performance aspect. You can write automated program to create new folder structure.
- The thumb rule of RDBMS is data integrity, If you are storing images in file system then the image data is disconnected with a database system.
- You should also take care about a security of file directory, if someone deletes your image files, then your application will 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 require 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 size of image data.
- You can also commit image data like any other data.
- The storing images into database system is very memory consuming.
- Imagine, If you stored millions of images in the database and each size is around 60 KB. In this situation, you have to use your SELECT statement properly otherwise this will create performance issues. You can not 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 then one new FileStream data type gives a very good optimized approach for storing files in database system.
” Conclusion… “
You should take decision based on your system complexity and scalability. I suggest you to go with File System and Database Storage is not allowable, but still it is advisable. Management is always easy with database storage, but will create a performance issue in some circumstances. Management is quite complex with file system, but you will get more performance.
This is my view and conclusion, but you can take a decision base on all above facts and figures.
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.