1

I recently had an interview. In the context of my mini project explanation, the interviewer asked me "where did you store the users uploaded image files?".

I replied that I used the file system rather than database. I also added that doing so wouldn't degrade the performance.

(Those images can be viewed by anyone, so there might be accesses from many users for an image).

To my surprise, he said that when your file is accessed by many, then you should use the database.

I argued with him that when the data has no concerns with atomicity, consistency, isolation, durability then why use a database.....

But he kept saying that when multiple users are accessing same file, then a database is to be used. He also said that many organizations do the same and that-why would there be a blob type in databases if storing files is not done in database.

I nodded to him; I didn't want any further debating.

So, now I'm confused. Is what he said true? Should one use a database for files when there are multiple accesses? Do many organizations do that? If yes, please explain me why is that so.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
flnone
  • 11
  • 1
  • possible duplicate of [Storing Images in DB - Yea or Nay?](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay), please also look at the "Related" links on this page. – Mat Feb 19 '12 at 08:15
  • 2
    Perhaps this was the interviewer testing how you handle authority and conflict. – Chris Eberle Feb 19 '12 at 08:18
  • possible duplicate of [Is it good to store images in database or file system?](http://stackoverflow.com/questions/877640/is-it-good-to-store-images-in-database-or-file-system) – Jonathan Leffler Feb 19 '12 at 08:27

2 Answers2

0

As my understanding, you should store file path in DB to improve performance, BUT absolutely different opinion storing image data in DB, this is completely wrong. normally database should keep high efficiency, reliability, so don't make database file is too large, I am sure my concept is definitely true. so your understanding is true, in order to improve performance when many users access one file at same time, you have to use other cache solution.

Sean
  • 1,806
  • 1
  • 13
  • 15
  • thanks,next time,if some interviewer raises this issue,i'll say-"im backed by stackoverflow guys". – flnone Feb 19 '12 at 15:39
0

The issue for me is two fold

A) backup - if images in db then the db will get much larger, if images in filestore then need to have two backup schemes - DB and filestore

B) retrieval - getting blob/binary datatypes in and out of DB is no as simple as plain datatypes and some ORM tools can not handle this.

extra considerations is cost of storage, can have very fast disks on db server and slower but very much bigger ones on a file server - get return on investment.

Personally i store images in a fileserver and link in the database

Simon Thompson
  • 708
  • 6
  • 14