SPUG:CGI header question

Peter Darley pdarley at kinesis-cem.com
Thu Jun 19 11:56:48 CDT 2003


Hi Aaron,
	A partial rebuttal :)

	I can see a lot of reasons to keep binary data in a database, some of which
are:
		I want to have central data storage, meaning a single machine that servers
all the data/files/etc.  If I store stuff in the database I don't have to
mess with other paths of data from my central storage to the web server(s).
It may be easy to set up a nfs share or whatever (which isn't actually the
case), but then I need to maintain twice as many services on the server,
secure twice as many access points, and rely on systems that are harder to
secure (NFS vs. database access).

		When performing backups I only have one thing to back up; the database.
If data is stored in the FS and in the DB I have to back up both and it gets
to be significantly more work backup and restore.

		I don't have to have extra functions/etc to work with/delete/whatever
data.  I can treat all data the same and have the same functions for working
with them.  There's nothing about binary data that is magically different
from other data, so why have a whole second system to work with it?

		Database limits are far less restricting than file system limits.  I don't
know a lot about files systems, but it's my understanding that you are
limited to the number of files in a single directory.  I do know a lot about
databases however, and I know that there's no problem storing millions and
millions of records in a single table.  If I exceeded the limits of the file
system in a single directory I then have to start making trees of
directories to hold all my files, which makes for a huge mess.  I currently
have directories for a system I wrote that didn't store stuff in the
database, and I can't go into the directory and do a 'rm -rf *' because
there are more files than rm can deal with.

		In general databases are far easier to work with.  That's why people talk
about 'making the file system work like a database' and never talk about
'making a database work like the file system'.

Thanks,
Peter Darley

-----Original Message-----
From: spug-list-admin at mail.pm.org [mailto:spug-list-admin at mail.pm.org]On
Behalf Of Aaron Salo
Sent: Thursday, June 19, 2003 9:26 AM
To: SPUG
Subject: Re: SPUG:CGI header question


At 08:52 AM 6/19/2003 -0700, you wrote:
>	I'm working on a project where I'm storing media (photos, sound files) in
a
>database and serving them through a perl script.  My image tags look like
><img src='Photo.pl?PhotoID=14232'>, which works fine.  What I'm looking for
>advice on is that since this is a perl script browsers wont cache the
>result, so it wants to download the images again weither it is new or not.

Hi Peter,

<rant>
files belong in the *file system*
data belongs in the *database*
</rant>

sorry, one of my pet peeves. forgive me in advance if this is one of those
projects where these decisions were made for you and you're just trying to
minimize the damage.

seriously, if you store a pointer in the database to the image file, and
leave the image file in the file system, and then roll up the IMG SRC tag
in the page by deriving the path to the image from the db pointer, all
normal browser caching mechanisms will perform as intended, thus averting
the problem you're trying to correct. using your current method

<img src='Photo.pl?PhotoID=14232'>

the browser cannot cache the stuff as you correctly point out, but by
putting those images in the file system and rolling up those tags normally
in your CGI output page

<img src='/path/to/image/from/the/database/call/14232.jpg'>

this is no longer a problem.

it has always seemed odd to me that people wish to store images in a
database as blobs. why would you go through all the work to store, kick
headers, emit streams of binary and contribute to the database equivalent
of global warming (increased backup times, more overhead, etc) by bloating
your tables with binary storage, when you can just keep it in the
filesystem and store the information necessary to retrieve it from there?
can someone tell me where I'm missing the point here??

hth
aaron



_____________________________________________________________
Seattle Perl Users Group Mailing List
POST TO: spug-list at mail.pm.org
ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, U-District, Seattle WA
WEB PAGE: www.seattleperl.org




More information about the spug-list mailing list