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 Blob/Clob or Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Blob/Clob or Files" Watch "Blob/Clob or Files" New topic
Author

Blob/Clob or Files

fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
What are the advantages of Blob/clobs over files, assuming that the files are non-corruptible and safe?

Instead of storing data as blobs, why shouldn't i just store them as files on hdd and store the path in db?
Please advise.

Also, when should one be opted over another?
I need to store movie files of the order of max 50mbs. What should i use?

Please advise.
Also, whats the difference between blob and clob, other than one being binary? A difference in layman's terms.

Thanks a lot in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Storing data on the file system and in the database weekens the data model. You can't impose a not null constraint for the file for example. Also the file system is not a transactional resource. If you create a record in the database pointing to a file and the file save stage fails you'll have to handle the rollback manually. Another thing is the file system is a difficult resource to access from a distributed environment - at the bare minimum you are probably going to have to introduce some OS specific access stuff (i.e. different UNC syntax) plus some admin overhead to maintina a share or how ever you implement this.


Also, whats the difference between blob and clob, other than one being binary? A difference in layman's terms.

A blob == Binary large object, i.e. any binary data. Clob == Character large object i.e. specifically character data.
[ May 09, 2007: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
So, does it imply that there are no performance advantages of blob over file systems?
In most of the projects, i have seen files being stored on hdd and paths being held in db. Does this have anything to do with number of files or size of files?

Thanks for the transactional implications of a file system storage.
fahad siddiqui
Ranch Hand

Joined: Jun 14, 2006
Posts: 85
Have a look at this link:
http://databases.aspfaq.com/database/should-i-store-images-in-the-database-or-the-filesystem.html

What would you advise me to use for storing video files which will be streamed onto the webpage when clicked? This would be strictly a single video being played when clicked on its image.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


So, does it imply that there are no performance advantages of blob over file systems?

There will probably be a performance difference. But these differences (as with most performance issues) will be very much specific to your environment. I would guess that there is a bigger overhead streaming the file into the database before the database persists it to the file system simply because using the file system direct misses the DB step. Performance is a smaller concern than some of the other issues I highlighted though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Blob/Clob or Files
 
Similar Threads
reading a very complex file and inserting in database
sample JSP code to upload file into database?
How to convert an object into BLOB
XML, flat files to database
Understanding Byte Data and Character Encoding