Store Image in Database or File System - Which is Better?

There are different pros and cons of saving images file into the database.

Saving Image Files in Database Pros & Cons:

Pros:

  1. Easy indexing/searching of image
  2. If you want to save and secure sensitive/confidential Images like employee face images.
  3. Integrity and consistency is good as the image save with data.
  4. A database backup will automatically backup the images too.
  5. Access to image is easy

Cons:

  1. Slow access to the image when you have more images
  2. Require more resources on the server.
  3. The database grows quickly consequently database backup will require more time.

Saving Image  in File System Pros & Cons:


Pros:

  1. Enable quick access to the image, 
  2. Easily viewable on the server through image viewer/browse.
  3. Performance is better even a large number of files are present.
  4. Easy backup

Cons:

  • Deleting the record will require deleting the file separately.
  • Low security of image.
  • Data and file link inconsistency may happen
  • No transactional control using SQL transaction.
  • Searching/Indexing is difficult

Ref:

  1. https://teamtreehouse.com/community/storing-image-in-database-compare-with-storing-at-the-folder-server
  2. https://www.quora.com/Difference-in-storing-image-in-database-table-vs-storing-image-in-folder-and-save-its-path-in-database-Which-is-better-and-why-PHP
  3. https://habiletechnologies.com/blog/better-saving-files-database-file-system/
  4. ChatGPT

Post a Comment

0 Comments