Storage of Binary Data

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Postgres SQL language list" <pgsql-sql(at)postgresql(dot)org>
Subject: Storage of Binary Data
Date: 2006-07-25 17:05:37
Message-ID: bf05e51c0607251005i58e836b7u51f411e103c242@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
==================================================================

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Hammond 2006-07-25 19:31:35 Re: SQL generator
Previous Message Aaron Bono 2006-07-25 15:00:35 Re: About Div