0

I am about to create an ASP.NET MVC app which will have over 2000 products and each products will approx 20 photos. The app will be asp.net mvc app and

I am using sql server 2008 r2 to manage my data. which way is the better approcah here;

  • Uploading pictures to a path and storing their file names to database in order to be able to make a relation to each other.
  • Storing pictures inside the database as byte as well and retreive them from there when needded.
tugberk
  • 57,477
  • 67
  • 243
  • 335
  • 1
    possible duplicate of [Storing Images in DB - Yea or Nay?](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay) – Mat Jun 26 '11 at 09:26
  • The other question is out of date I'd say if you use the FILESTREAM type storage – gbn Jun 26 '11 at 09:53

3 Answers3

1

Definitely storing as a path rather than the byte array. This means you can easily change the actual image itself without having to alter any code or muck around in SQL (as long s the new file has the same name as the old one).

Hope this helps.

stuartmclark
  • 1,203
  • 13
  • 22
1

definitely in the filesystem (store path) is better, i have done both in the past.

Against SQL server to store images A) betting data in and out can be more difficult as have to used blob type objects and some ORMs don't really cater for this B) your data base is much bigger so effects your backup/restore policy. The more frequently you backup the better but space will be increased. Storing in file, yep you still need to backup but backing up filesystem is easy. C) when you run out of storage space you just add another NAS drive / server and start storing images there, so scales horizontally

The common perception is not as good as data stored in two places but for me its better as the type of data in stored in the best storage medium for the data types ..

gbn
  • 422,506
  • 82
  • 585
  • 676
Simon Thompson
  • 708
  • 6
  • 14
1

In the database using FILESTREAM which combines the 2 ideas (file and database)

FILESTREAM integrates the SQL Server Database Engine with an NTFS file system by storing varbinary(max) binary large object (BLOB) data as files on the file system. Transact-SQL statements can insert, update, query, search, and back up FILESTREAM data. Win32 file system interfaces provide streaming access to the data.

This changes the file vs database arguments

If you want to store paths only, then you'll have to accept the fact that images and database will get out of synch over time.

gbn
  • 422,506
  • 82
  • 585
  • 676
  • FILESTREAM definitely appears the way to go however SQL Server must be specifically enabled. Can you think of a reason why a hosting service will balk at enabling FILESTREAM on a shared server? – StuTheDog Jun 27 '11 at 14:23
  • @StuTheDog: can't help you there sorry. I've never used hosted SQL boxes – gbn Jun 27 '11 at 14:30