It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Storing uploaded files straight into a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Storing uploaded files straight into a database" Watch "Storing uploaded files straight into a database" New topic

Storing uploaded files straight into a database

ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
Hi to all,

This has been bugging me for some time now and I finally thought I would come out clean and ask. I am aware that many realational databases can store files such as images directly into them but I don't see this done much.

Let me explain, I work for a web development agency here in the UK and I've worked there for over the past 3 years as a web developer. I have had the pleassure of maintaining hundreds of sites over that period;) Most of the sites are backed by either MySQL or MS SQL Server.

When developers want to upload, say a document as part of a database news article they will simply store the file somewhere on the hard drive and then store a reference to it in a database column. I have never seen a developer storing the file directly into the db. Is this how it's done normally. I'm just curious. The only reason I think people never store files straight into the db is because the files might take up too much space.

Please enlighten me.

Best regards,
[ December 30, 2006: Message edited by: ernest fakudze ]

In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
This very subject has been discussed recently, and several times before that.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

I also added it to the FAQ the last time this question was asked.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
Thanks for pointing me in the right directions guys. I forgot to search the forums first.

Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
Storing a link to the graphics file (instead of inserting the whole file into the database), is:

1. faster
(a disk access, vs a database connection & subsequent data transfer)
2. more efficient
(see above)
3. More portable
(different databases have different syntax for blob's)
4. Easier to code
5. Easier to back up

which is probably why that's the way it's usually done (except for stuff like MS Sharepoint, of course ;-))


Paul M. Santa Maria, SCJP
I agree. Here's the link:
subject: Storing uploaded files straight into a database
It's not a secret anymore!