X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6561A9FAE4E for ; Tue, 25 Jul 2006 14:06:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 69318-02-2 for ; Tue, 25 Jul 2006 14:05:50 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by postgresql.org (Postfix) with ESMTP id BFBA79FA682 for ; Tue, 25 Jul 2006 14:05:49 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so294265nfc for ; Tue, 25 Jul 2006 10:05:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=ZTSlBjttA1CeachRG2cQcdzOzt5YCvq82A2M7D9qCapYH3Q2Y48XTYulx+nZsJE3i0UvsUa+JgLT7Np+XJyrWeSghIIMBcsxZA93WUf6/Fk7Q+6EQ/gAajS15IHbWrYqwFjK/172LWXqqeaY4wqhpT9ZGtQ2pRgurjczL3ydk50= Received: by 10.78.185.7 with SMTP id i7mr2456973huf; Tue, 25 Jul 2006 10:05:38 -0700 (PDT) Received: by 10.78.32.10 with HTTP; Tue, 25 Jul 2006 10:05:37 -0700 (PDT) Message-ID: Date: Tue, 25 Jul 2006 12:05:37 -0500 From: "Aaron Bono" To: "Postgres SQL language list" Subject: Storage of Binary Data MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_148505_21371337.1153847137976" X-Google-Sender-Auth: f8fc4ddf1646ee9e X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.052 tagged_above=0 required=5 tests=AWL, HTML_10_20, HTML_MESSAGE, SPF_PASS X-Spam-Level: * X-Archive-Number: 200607/308 X-Sequence-Number: 25882 ------=_Part_148505_21371337.1153847137976 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ================================================================== ------=_Part_148505_21371337.1153847137976 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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
================================================================== ------=_Part_148505_21371337.1153847137976--