views:

116

answers:

5

My client have created a script in php+mysql that saves images directly in the database and every images has url like this: www.example.com/image.php?id=421

In your opinion this is a very wrong solution ? Should I rebuild all the site ?

There are about 1000 visits per day and about 600 images in the database.

This is the site: http://tinyurl.com/3xkxdsw

+3  A: 

Is there a good reason for storing them in the DB? There can be some valid reasons to do this. I am assuming these are client images not the images needed to display the site itself (i.e. background images, things inside img tags).

As for rebuilding the site. It would likely improve performance, but at a 1000 hits a day it may not be worth the time it would take. assuming site performance was acceptable and it did not incur extra hosting fees etc. I would be inclined to leave it until I was redesigning the site.

Steve Robillard
+2  A: 

If you read @Gazler's link from comment, it really boils down to few questions:

  • is there any problem with performance? [Y]
  • do you store any additional information, or just images itself? [Just images]
  • do you plan (or hope) to attract much more users in future? [Y]
  • are you limited in size of your db? [Y]

if you answered with answers in brackets, then it might be good for your website to put images out of database, otherwise, you can leave it as it is and save yourself some time and/or nerves

Adam Kiss
+1  A: 

There are good and bad points. And it depends on who you are. about 5 years ago it became all the rage to put all images in the database.

But with server space sizes bigger today, its not really about saving space.

A negative would be you will always require understanding of server side programming to use images. If this development my be passed to another person, it could prove problematic.

As far as I can see, if it works, it works and I can't see performance issues - it seems very quick.

Glycerine
+4  A: 

Images files are files, unless there is compelling reason to store them in the database, the place they belong is the file system, where you get benefits like easy backup and replication, distributed across multiple machines, directly served by the webserver, and all the last-modified-date and etag supported by the webserver to achieve better performance, etc.

if the number of images is expected to grow, and different sizes of one image are expected to be created (e.g. thumbnail images etc.) in the coming release, a plan to migrate images from db to file system is strongly suggested.

Zhang Yining
+1  A: 

Just because it can be done, doesn't mean it should be.

I always store meta data about the images (filename, location, other attributes) in the database, and store images externally in the file system. There is very little benefit, imo, of actually storing images in an SQL database. Once they are in there, they are very inconvenient to use.

EJB