I'm working on an ASP.NET web app, this web site is hosted on a VDS (virtual dedicated server) which has a big hard drive (30 GB). Users can upload pictures and currently images are stored in database image columns (SQL server 2008). Is it better to store images as files on hard drive instead of saving them in database? what are pros and cons of each method? I think there would be about 100 pictures each day so I suppose database will grow quickly and finally I'll have a really big MDF file!
Asked
Active
Viewed 1,634 times
0
-
3also consider case of taking the database backups. – Sen Jacob Nov 07 '12 at 16:00
-
2Check out filestream in sql server http://technet.microsoft.com/en-us/library/bb933993(v=sql.105).aspx. – Prescott Nov 07 '12 at 16:01
-
When storing as file, if you need to change the folder structure, consider updating all image links, when image is stored in DB, you don't want to care about the folder structure of your application – Sen Jacob Nov 07 '12 at 16:08
-
If you store the links to images as url, it will be easier when you need to store external image urls as an alternative option to uploading to your own server – Sen Jacob Nov 07 '12 at 16:11
-
1when you want to migrate your server to somewhere else, it will be easier if the images are in the single DB file, otherwise you might have to migrate thousands of images and it might take more time than others. (Only applicable in rare cases, you can neglect this point) – Sen Jacob Nov 07 '12 at 16:15
-
The Blobs are actually stored as files in a folder. The Blobs can be accessed using either a database connection or over the filesystem. – Sen Jacob Nov 07 '12 at 16:19
-
see these links http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay – Sen Jacob Nov 07 '12 at 16:19
-
http://stackoverflow.com/questions/8739188/pro-cons-of-storing-filespictures-in-a-sql-server-for-a-website – Sen Jacob Nov 07 '12 at 16:20
-
[To BLOB or not to BLOB](http://research.microsoft.com/pubs/64525/tr-2006-45.pdf) – Remus Rusanu Nov 07 '12 at 16:50
1 Answers
2
It depends on your priorities. There is no blanket answer for which method is the best. However, unless you foresee the need to utilize database backups for these images, storing pointers to the file-system should be adequate. Otherwise, the filestream option is best for storing images in a database.
PinalDave wrote on this subject and you may find the discussion interesting: http://blog.sqlauthority.com/2009/07/13/sql-server-blob-pointer-to-image-image-in-database-filestream-storage/

eclectronica
- 116
- 1
- 2