[PHP-DB] Re: Images on MySQL

2002-03-29 Thread Luis R. Sales Glez.

Hi Steve  *:

Based on my experience, not only for MySQL, but any Database, I think it's
better to keep just links to images instead of keep them in the database.

Some of the reasons are, for example, when you need to update an image,
you don't need to touch the database, only change the file. Another one
would be if you try to move to another Database and it does not support
those types, then you won't be able to keep your images in the database.

One more... In a heavy traffic site or environment it would be faster and
more efficient to serve the images directly from the file system than from
the database having several users connected at the same time.

Anyway, there is not a solution that is better than the other. It all
depends on what you want to do, how you want to do it, and the
environment, specifications and resources that you have.

Regards, 

-- 
Luis R. Sales Glez.
Database Administrator
Information Systems  Solutions
Sony Latin America Inc.
Mailto: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] RE: Images on MySQL

2002-03-29 Thread Andrew Chase

The kneejerk response always seems to be #2, store images in the filesystem
and store their paths in the database.

I like to compromise: store the original image in a dedicated image data
table in the database (keep a separate table for image meta data
(date/title/category/whatever) for faster queries, link the two with an
'image_id' field), then have the script which displays the image check for a
copy in a specified directory in the filesystem; if it's not there, yank a
copy from the database, resize/watermark as needed, and store in the
directory.  Otherwise, the script can just write the img href on the fly.

This way you don't wind up with the overhead of pulling images from the DB
on the fly every time (just the first time a script looks for the image),
but you maintain a pristine copy of the original image in the database-
especially nice for uploading photos straight out of a digital camera
without monkeying around in Photoshop/GIMP; you get the web-sized copy in
your /images directory, but you keep the full resolution copy in the db if
you ever need it for something else.  And if you ever need to move the db to
a new server, you don't need to worry about moving all the image files
separately.

I suppose storage space might become a factor if the number of images
climbed into the high hundreds or thousands, but it works great for me in
smaller applications.  YMMV, caveat emptor, etc.

-Andy

 -Original Message-
 From: Clever [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 28, 2002 3:35 AM
 To: [EMAIL PROTECTED]
 Subject: Images on MySQL


 Hi,
 I'm designing a site and I have to store a lot of images.
 Which is the best for speed?
 1) Store all images on a MySQL table?
 2) Save them on disk like normal files and only have pointers to
 them on the
 database?
 Thanks a lot
 Clever Anjos





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php