I have a somewhat philosophical question about best practices when storing binary data.
For my web projects, we have been storing binary data (like images, PDF's, etc) on the hard drive of the web server instead of the database. Within the database, we keep information, like whether an image is present, in a separate column.
For example:
CREATE TABLE site_user (
site_user_id BIGSERIAL NOT NULL,
has_profile_image BOOLEAN DEFAULT false NOT NULL
CONSTRAINT site_user_pkey PRIMARY KEY (site_user_id)
);
And then store the profile image at:
[web root]/images/siteuserprofile/profile-[site_user_id here].jpg
We also have a back end process that then checks these files into CVS to help maintain version control.
My questions are:
* What other options are people using to store data like this?
* What are the advantages/disadvantages of these storage methods?
I have been very reluctant to store the binary data in the database for the following reasons:
* Performance because you cannot just save the data to the file system, you must
interact with the database to get/save contents
* Increases complexity of application
* I have had problems with saving binary data using JDBC before (that was with
Oracle 7 though)
* I am concerned about how well the data backups will work - there have been several
people who have had problems with backing up and restoring binary data on this
list
I am trying to develop some best practices so any input you guys have is welcome!
Thanks
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
==================================================================
- [SQL] Storage of Binary Data Aaron Bono
- Re: [SQL] Storage of Binary Data Andrew Sullivan