This discussion is archived
6 Replies Latest reply: Jul 21, 2010 8:53 AM by 807580 RSS

either filesystem or database for image

807580 Newbie
Currently Being Moderated
hi experts,
i want to know that which is better to store images either file-system or database?

i am developing a social networking web site and there will be too many images and also to be of larger size.

Thanks
Shams
  • 1. Re: either filesystem or database for image
    YoungWinston Expert
    Currently Being Moderated
    shams.hq wrote:
    i want to know that which is better to store images either file-system or database?
    i am developing a social networking web site and there will be too many images and also to be of larger size.
    It really depends what you want to do. If they're directly linked to some other entity (eg, a person/client's photograph), I suspect a database would be better; if it's simply a library of images then a directory or tree may well be sufficient (and simpler).

    Winston
  • 2. Re: either filesystem or database for image
    807580 Newbie
    Currently Being Moderated
    Hi,

    I agree what YoungWinston said.

    I developed a dating site and stored the images and video files on file-system in individual folders. The files were resized and saved with 2 names (one given by user, one given by me to be unique). It worked well. Our database was enourmous and we avoided to store user's files(images and videos) as blobs in the db.

    Hope this helps.

    Regards,
    Sergiu
  • 3. Re: either filesystem or database for image
    807580 Newbie
    Currently Being Moderated
    Thanks to both of you for your suggestion.

    Thanks a lot.
  • 4. Re: either filesystem or database for image
    807580 Newbie
    Currently Being Moderated
    If by database you mean relational database, then I would stronly advise storing the location of the files, and not the files themselves - and also to organise them meaningfully on disk.
  • 5. Re: either filesystem or database for image
    forumKid2 Explorer
    Currently Being Moderated
    One thing to consider is clustering. If you have multiple clustered servers for failovers, etc, then likely your files (if kept on the file system) will be duplicated on multiple hosts and is cumbersome to manage. If you keep the files in the database then you can have one database (clustered or not) and avoid having multiple copies of the same file.

    There are advantages and disadvantages to both situations. In a non-clustered environment, I tend to keep all files on the filesystem. It keeps the database size to a minimal. In clustered environments I tend to keep them in a separate table and/or schema where other tables know how to retrieve them by key, etc.

    HTH
  • 6. Re: either filesystem or database for image
    807580 Newbie
    Currently Being Moderated
    ForumKid2 wrote:
    One thing to consider is clustering. If you have multiple clustered servers for failovers, etc, then likely your files (if kept on the file system) will be duplicated on multiple hosts and is cumbersome to manage. If you keep the files in the database then you can have one database (clustered or not) and avoid having multiple copies of the same file.

    There are advantages and disadvantages to both situations. In a non-clustered environment, I tend to keep all files on the filesystem. It keeps the database size to a minimal. In clustered environments I tend to keep them in a separate table and/or schema where other tables know how to retrieve them by key, etc.

    HTH
    Very valid points - another note: if you do opt to store them on you filesystem, do not do so on your app servers. As ForumKid2 pointed out, it's messy.

    Have them stored on a seperate server, and mount this location on your app servers.