Re: what is the best way of storing text+image documents in postgresql

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Arash pajoohande <apajoohande(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: what is the best way of storing text+image documents in postgresql
Date: 2011-06-08 13:06:57
Message-ID: 4DEF73F1.9030101@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/08/2011 06:13 PM, Arash pajoohande wrote:

> 1. save .doc documents in bytea columns. and show them with a word
> reader in web page (disadvantage: it needs a proper .doc reader
> installed on user computer)

1a: Convert the .doc files to a standard format like PDF that most
browsers can display. That's what I'd do.

> 2. convert document to html format and store html code as string
> (disadvantage: images will remain in file system)

You could always store images as 'bytea' fields on a subtable.

CREATE TABLE doc (
id serial primary key,
doc_html text,
...
);

CREATE TABLE doc_images (
id serial primary key,
doc_id integer references doc(id),
image_data bytea not null
);

There are advantages and disadvantages to storing files in the database
vs in the file system. It's been discussed to death recently, so see the
mailing list archives.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tarabas 2011-06-08 14:32:54 Re: [bulk] Re: Non returning Transactions/Many Locks in Postgres 9.0.4 and 9.0.1
Previous Message Gaëtan Allart 2011-06-08 12:59:05 Abnormal long SELECT query under postgresql 9.0.4