Alex Rivera | Logout

Should I store my images in the database or folders?

Asked 2009-04-03T09:39:02.087
26

Possible Duplicate:
Storing Images in DB - Yea or Nay?

Hi

At the moment each Company on my website have 1 picture they can add to their profile. I save that image into the database....its their Company Logo.

Now i want to allow them to add more pictures. Now i don’t know if i must save it all in the database or save it in folders????

Reason why i think folders will be better is because there are so much nice articles with fancy silver light kinda features that i can use but all of them only cater for images saved in folders.

And since i am not THAT good its hard for me to change the code to look at the database instead of the examples that uses folders for image retrieval.

I would like to add something like this to my website (browsing through the images). Any code examples for me on how to do this when images are saved in the database? I am using ASP.NET with VB.net. Click here to view what i am talking about

Any ideas guys?

Regards Etienne

Edit
Report

2 Answers

6

Two thoughts on this:

  1. Use the filesystem. But make sure you design your scheme well enough that any one folder is not overloaded with images and it becomes something of a nightmare to manage. For instance, you can tree it out with first or last letters of the identifier, or subsequent positional notation. Your mileage will vary, so make sure the scheme fits your data set (images) size. No need to go to detailed lengths if you're only managing, say, 20 images.

  2. Use SQL Server 2008. It has a new datatype called filestream while will save the images to the filesystem but allow you to retrieve it via standard database queries. See http://msdn.microsoft.com/en-us/library/cc949109.aspx for more information.

These aren't exclusive choices, but at the very least, I'd recommend option #1 for the sheer fact that you'll get better performance out of using a filesystem-based-scheme rather than storing and reading blobs out of a database.

answered 2009-04-03T14:50:39.233
4

The approach I generaly use is to copy images to a folder and keep the relative URLs in the database. The downside to this approach is that if someone deleted the images you end up with "image not found" in your web pages unless you check everytime you render a page.

answered 2009-04-03T09:42:14.717

Your Answer