Should I put pictures into a database?

This is a discussion on Should I put pictures into a database? within the PHP General forums, part of the PHP Programming Forums category; On Wednesday 21 November 2007 03:14:43 Ronald Wiplinger wrote: > I have an application, where I use pictures. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 11-28-2007
AmirBehzad Eslami
 
Posts: n/a
Default Re: [PHP] Should I put pictures into a database?

On Wednesday 21 November 2007 03:14:43 Ronald Wiplinger wrote:
> I have an application, where I use pictures. The size of the picture is
> about 90kB and to speed up the preview, I made a thumbnail of each
> picture which is about 2.5 to 5kB.
> I use now a directory structure of ../$a/$b/$c/<pictures>


I rather to store images on the file-system, since database is another
level over the file-system. However, I still need to store a pointer for
every image into the database. This leads to storing the file names
twice: one time in file-system, and one time in db.
Isn't this redundancy?

Sometimes we can avoid this, especially if we have an image per
record (e.g., Users' Avatars).

Suppose you allow each user to upload a GIF/PNG/JPEG image;
the below code assigns the correct image for every user:

foreach ($users as &$user) {
$user['avatar'] = reset(glob('../img/avatars/' . $user['id'] .
'.*'));
}

If you can grant the images are .GIF, then you can reduce the
overhead of searching for images:

foreach ($users as &$user) {
$user['avatar'] = '../img/avatars/' . $user['id'] . '.gif';
}

Regards,
Behzad

Reply With Quote
  #12 (permalink)  
Old 11-29-2007
Robin Vickery
 
Posts: n/a
Default Re: [PHP] Should I put pictures into a database?

On 28/11/2007, AmirBehzad Eslami <behzad.eslami@gmail.com> wrote:
> On Wednesday 21 November 2007 03:14:43 Ronald Wiplinger wrote:
> > I have an application, where I use pictures. The size of the picture is
> > about 90kB and to speed up the preview, I made a thumbnail of each
> > picture which is about 2.5 to 5kB.
> > I use now a directory structure of ../$a/$b/$c/<pictures>

>
> I rather to store images on the file-system, since database is another
> level over the file-system. However, I still need to store a pointer for
> every image into the database. This leads to storing the file names
> twice: one time in file-system, and one time in db.
> Isn't this redundancy?


Think of it as a foreign key.

-robin
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0