Should I store images in my database?

liptonIcedTea

Well-known member
Joined
Jan 18, 2007
Messages
89
Programming Experience
1-3
Hi,

I have SQL Server 2000, and I've been told that storing images or large clunks of data into your database is inefficient. Is this true?

I have some user uploaded custom images that I would like to display on a personalised website and I have two ways to store it.

(1) just in a table in my database
(2) in a file on a directory on my web server. This file is named after a GUID which is referenced by a table in my database. So when the user wants to access this image, it'll ask the database for the GUID and then retrieve the corresponding file from the web server.

Could anyone give me any opinion about the advantages/disadvantage of each method?
 
The filesystem is the most efficient file storage (it also stores the db files). There is also no use for the db engine to do different searches upon byte data fields. One issue could be user access, if the db is the only access point (ie no filesystem access) then the image must come either directly from db or via another middle-tier like a service/webservice that operates against the db/file backend. A webpage is a frontend that usually can access both the db and the filesystem. Some more input: Should I store images in the database or the filesystem? This is also a very discussed topic on the internet, try for example searching "store files in database" and similar terms.
 
Hi
I hope the following advantages and disadvantages I have outlined are helpful.

The advantages are:
1. Making it easier to backup your data and images, as there all in one file.
2. Security. Sometimes if you have a large number of images that you don't want to be publically accessible you can.

The disadvantages are:
1. Increases the size of the database file.

These are just some points that I can think of off the top of my head. I am sure there are others but at the end of the day its a judgement call as to what best suits your needs.

Regards

ScottyB
 
Back
Top