File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes what should i use for accessing image files - filesystem or database ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "what should i use for accessing image files - filesystem or database ??" Watch "what should i use for accessing image files - filesystem or database ??" New topic
Author

what should i use for accessing image files - filesystem or database ??

nagarjuna borra
Ranch Hand

Joined: Jan 14, 2012
Posts: 41
i recently had an interview.In the context of my mini project explanation the interviewer asked me "where did you store the users uploded image files ?".

I replied that i used the filesystem rather than database...I also added that doing so wouldnt 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 databse.....

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

I noded to him,I didnt want any further debating.

So,now im confused,is what he said true?..should one use database for files when there are multiple accesses??...do many organistions do that??
if yes,please explain me why is that so.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Things are rarely as clear cut as yes/no - it generally depends on the circumstances. If the files are accessed so frequently that performance is an actual -not just putative- concern, then they should probably be cached regardless of whether they're stored in a DB or a file system.

he also said that many organisations do the same

Yes, and many other organizations use the file system.

why would there be a blob type in databases if storing files is not done in database.

For other kinds of binary data. A file is just a container for the data you care to put into it; with the same right you could ask "why is there an integer datatype in SQL when I can store the number in a file?".
nagarjuna borra
Ranch Hand

Joined: Jan 14, 2012
Posts: 41
Tim Moores wrote:If the files are accessed so frequently that performance is an actual -not just putative- concern, then they should probably be cached regardless of whether they're stored in a DB or a file system.


but,I think in databases-there will be some overhead compared to filesystem...
in both the cases we get the file from the disk,but in database we need to get a connection,and there will be some processing done by the DB.

he also said that many organisations do the same
Yes, and many other organizations use the file system.


the interviewer was refering to DB's..i mean he was saying "many organisations use DB's for storing files that are frequently accessed".
he was'nt agreeing with using filesystem.

Thanks for your concern.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I think in databases-there will be some overhead compared to filesystem... in both the cases we get the file from the disk,but in database we need to get a connection,and there will be some processing done by the DB.

It's not a given that DB data comes off the disk - if the file is as frequently used as the problem makes it sound, then it may well be in memory (cached by the DB). Without knowing a lot more it's not possible to say which approach is to be preferred; with respect to performance, gut feelings about what ought to be faster often turn out to be incorrect. What's more, without runtime data about how often the file is accessed, and by whom, there is *no* basis for making optimization decisions. Premature optimization is the root of all evil, to paraphrase a more insightful man.

the interviewer was refering to DB's..i mean he was saying "many organisations use DB's for storing files that are frequently accessed". he was'nt agreeing with using filesystem.

By saying "many" he acknowledged the facts on the ground - which is that both approaches are commonly used.

(By the way, please edit your post to fix the "quote" tags. It makes no sense as it is now.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what should i use for accessing image files - filesystem or database ??
 
Similar Threads
deploy application in server
IBM Websphere 340
Display multiple images in JSP from MySql
Getting absolute path from file uploaded
Servlets Vs. EJB